I am trying to get this Node.js TypeScript definition to work, but WebStorm gives me a big list of errors with all the same message:
Reserved word 'this' used as name. This inspection reports on any uses of JavaScript reserved words being used as a name. The JavaScript specification reserves a number of words which are currently not used as JavaScript keywords. Using those words as identifiers may result in broken code if later versions of JavaScript use them as keywords.
An example piece of code where this error happens due to the return type:
Why can't the this
keyword be a type? Am I perhaps using an old TypeScript compiler or is it a mistake in the typing?
Edit:
To get rid of the errors I've just replaced all these this
types with the type of the containing class or interface. For example, the errors in the given example are fixed by changing it to this:
export interface EventEmitter {
addListener(event: string, listener: Function): EventEmitter;
...
}
Although, this is not a solution to the actual problem.
Am I perhaps using an old TypeScript compiler ... ?
Yes, upgrade to at least TS 1.7 to get polymorphic this support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With