-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Improve type safety of name
global variable
#15424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
related: #9850 @DanielRosenwasser |
@mhegazy @DanielRosenwasser Can you please also review this? |
@DanielRosenwasser any thoughts |
The resons we made it class C {
name: string;
method() {
doSomething(name); // not this.name
}
}
```
by making it `never` at least you will get an error and you will go back and check the source of the declaration.
`string | undefined` will put us back where we started for most users. |
as noted in #15424 (comment), |
name
global variable is still assignable tostring
type. Soname
is still unsafe.name: string | undefined
works better than current definitionname: never
.TypeScript Version: master
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: