-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Check typeof operator result #12697
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
I am sure we talked about this before but can not find the issue right now. The issues is this section:
It is allowed for engines to return some value outside this range. if you are using one of these engines, your code will be flagged as an error and you will need to cast to |
Can it be a compiler flag then? Similar to |
:D well, everything can be done under a flag. but we are getting strong feedback from customers that the number of flags is getting to be overwhelming, and they are having trouble what they need to set. So we would like to stay away from flags when possible. |
That's fair. Is there any engine in the wild that actually produce something outside of spec for |
Not that I know of. That is why I want to bring this back to discussion. I would expect this to catch more errors than block valid scenarios. |
@mhegazy With respect to the increasing number of flags, TypeScript is still simpler to configure than a lot of other tools, but regardless it certainly could be simpler than it is. Perhaps a notion of "presets", should be introduced. Perhaps this could also leverage the new configuration inheritance support (I'm not sure, might obscure things). I am thinking something like.
where the non-loose variants would be {
"compilerOptions": {
"strictNullChecks": true,
"noImplicitThis": true,
"noImplicitAny": true,
"alwaysStrict": true,
"allowUnreachableCode": false,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"allowUnusedLabels": false
}
} |
Throw a compiler error if
typeof
operator is compared to strings other thantypeof
operator resultsTypeScript Version: 2.1.1
Code
The text was updated successfully, but these errors were encountered: