im trying to instance a class passed as parameter to another, I have this in one file, ImportedClass.ts:
export default class ImportedClass {
public constructor(something: any) {
}
public async exampleMethod() {
return "hey";
}
}
And this in another, InstanceClass.ts:
interface GenericInterface<T> {
new(something: any): T;
}
export default class InstanceClass <T> {
private c: GenericInterface<T>;
public constructor(c: T) {
}
async work() {
const instanceTry = new this.c("hello");
instanceTry.exampleMethod();
}
}
And this in another, ClassCaller.ts: <--EDITED-->
import ImportedClass from './ImportedClass';
import ImportedClass from './InstanceClass';
const simulator = new InstanceClass <ImportedClass>(ImportedClass);
Then when I call it like this:
simulator.work();
It throw this error:
error TS2339: Property 'exampleMethod' does not exist on type 'T'.
Any help is welcome, thanks.