Przejdź klasę do ogólnego maszynopisu

export class ImportedClass {
    public constructor(something: any) {
    }
    public async exampleMethod() {
        return "hey";
    }
}

interface GenericInterface<T> {
    new(something: any): T;
}

export class Simulator<T extends { exampleMethod(): Promise<string> }> {
    public constructor(private c: GenericInterface<T>) {
    }
    async work() {
        const instanceTry = new this.c("hello");
        await instanceTry.exampleMethod();
    }
}
const simulator = new Simulator(ImportedClass);
simulator.work()
Talented Tapir