I'm struggling to understand where the problem with this implementation is. I have created a simple test class that implements a very simple interface with a constructor and the Typescript compiler is saying there is a problem.
BaseEntity.ts:
export interface IBaseEntity {
id: string
new(_id?: string, _data?: any)
}
Test.ts:
class Test implements IBaseEntity {
id: string
constructor(_id?: string, _data?: any) {
this.id = 'MOCK_ID'
}
}
error:
Class 'Test' incorrectly implements interface 'IBaseEntity'.
Type 'Test' provides no match for the signature 'new (_id?: string | undefined, _data?: any): any'.
I'm hoping someone can quickly point out where the issue is because it seems to me this is correct. Thanks in advance all.