I can't seem to figure out what's wrong with this code. I made a simple test class that follows an interface with a constructor, but the Typescript compiler is flagging an issue.
Here's BaseEntity.ts:
export interface IBaseEntity {
id: string
new(_id?: string, _data?: any)
}
This is Test.ts:
class Test implements IBaseEntity {
id: string
constructor(_id?: string, _data?: any) {
this.id = 'MOCK_ID'
}
}
The error message states:
Class 'Test' incorrectly implements interface 'IBaseEntity'.
Type 'Test' does not match the signature 'new (_id?: string | undefined, _data?: any): any'.
If anyone could quickly point me in the right direction, that would be greatly appreciated. It seems correct to me, but maybe I'm missing something. Thanks in advance!