interfaceIClassyAnimal{new(name:string):this;}classParrotimplementsIClassyAnimal{name:string;constructor(name:string){this.name=name;}}// Class 'Parrot' incorrectly implements interface 'IClassyAnimal'.// Type 'Parrot' provides no match for the signature 'new (name: string): this'.
I don't know all the answers, I simply experimented to write this post. It also can happen I miss a lot of things, or there are bugs in TS or some small details which I miss. All ideas are more than welcome. (TypeScript documentation seems to lag behind actual behavior sometimes)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In the new section, you wrote:
But it should be:
Doesn't seem to help typescriptlang.org/play/#code/JYOw... 🤔
I guess the only reasonable usage of
new
is this:code example from stackoverflow.com/questions/134070...
If you want to declare type of constructor you can do something like this:
Yes. I wasn't unable to check it, but I was sure I did something like that. But according to the docs
typescriptlang.org/docs/handbook/i...
Seems like you are right. Constructors interfaces declarations are mostly effective as function arguments.
I don't know all the answers, I simply experimented to write this post. It also can happen I miss a lot of things, or there are bugs in TS or some small details which I miss. All ideas are more than welcome. (TypeScript documentation seems to lag behind actual behavior sometimes)