-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Control flow not formed when using consts #11542
Comments
Why are you using a We could think about this as a suggestion but you'd definitely need to not have the |
I'm using |
After reading the TypeScript Language Specification; 4.18.6 The typeof operator I've changed the type of |
Approved change for next release |
TypeScript Version: 2.0.3
Code
Expected behavior:
Actual behavior:
Currently type guards are only limited to literals. Type guards are consumed at compile time and from this taken in mind variables defined with
let
orvar
seems natural to not result in proper control flow but type guards using constants defined withconst
should result in a proper type guard. Since the compiler already knows thatconst
s will not change their value ans so their value should be checked dose it evaluate to knowntypeof
return value to form a proper control flow else to result in a[ts] error
...The text was updated successfully, but these errors were encountered: