Say I have a class Test with a static method .plugin which takes a function. That function can run arbitrary code and extend Tests API.
const MyTest = Test.plugin(fooPlugin)
const test = new Test()
const myTest = new MyTest()
test.foo // does not exist
myTest.foo // exists
I've made a TypeScript Playground that I hope is close to working
When I add myTest.foo to the end of the example, .foo is typed as any. I would expect that the <typeof plugin> would return the type of the plugin function that I pass, not the generic specification?
If I replace <typeof plugin> with <typeof TestPlugin> then it works as expected.
Is there anything I can do to make this work, without changing the way the Plugin Architecture currently works?
If I slightly change the code (Playground link), myTest.foo gets typed correctly, but there are two TypeScript errors.