-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Typeof comparison expression should check right hand side value #9506
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
There are two parts here, first type of the return type of and two is to make a comparison between two a string literal type and a string literal an error, which would be a breaking change and prevent defensive coding patterns. |
For the record, in the spec's section on The
|
Good comments from Brian in #10594 |
Until this is normatively specified we don't want to encode this into the type system. A TSLint rule would be very easy to write. |
We did do this! 🎉 |
As I understood
typeof
operator can only returnundefined
,object
,boolean
,number
,string
,symbol
,function.
If the RHS is a string literal, I think it should check against the above values and throw an error on:
The text was updated successfully, but these errors were encountered: