I can't compile Typescript code because the compiler does not seem to understand the inheritance between my classes.
When I try to compile, I run into this error
Property 'create' does not exist on type 'new () => T'.
export abstract class Resource {
// creates a new resource and returns it
static async create<T>(this: { new(): T }, resource: T): Promise<T> {
const resource = ... // using "this"
return resource;
}
}
export abstract class ContainerResource extends Resource {
static async addToContainer<T>(this: { new(): T }, resource: T, containerId: string): Promise<T> {
r = await this.create(resource); // Property 'create' does not exist on type 'new () => T'.
// do some stuff
return r;
}
}
I except this code to compile. It does not work even with addToContainer<T extends Resource>
:(
Aucun commentaire:
Enregistrer un commentaire