I have the following example:
class Uncle { constructor(public name : string) { } talk() { return "Hello my name is " + name; } } let p : Uncle = new Uncle("Jo"); console.log(p.talk());
For certain typescript variable names (right now Version 2.1.4 ) will not complain that they are not defined in your program (in a method call, the name is used without it.). name
is one of those.
If I rename a variable, say firstName
, the compiler complains in truth ...
error TS2663: Cannot find the name 'firstName'. Did you mean an instance of "this.firstName"?
The same thing happens, for example. a window that is apparently supposed to exist.
My question (s):
- What variable names are supposed to exist and why?
- Is it possible to change this behavior (for example, in some lints you can specify which variables you expect to receive globally)?
source share