My issue lies in compiling Typescript code as the compiler doesn't seem to recognize the inheritance between my classes.
Whenever I attempt to compile, an error arises:
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 anticipate this code to successfully compile. However, even with
addToContainer<T extends Resource>
, it still doesn't work :(