-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 analysis: switch (true)
case
#8934
Comments
Unfortunately, the function f(x: First | Second | Third) {
switch(x.kind) {
case Kind.First:
x; // x is now First
break;
// etc
}
} Note that even if you rewrite to if (true === isA(action)) {
action; // action is not narrowed
}
if (isA(action)) {
action; // action is narrowed to A
} In order to keep things simple, narrowing only supports a few common syntactic forms. We do expand this list from time to time, but I don't think the |
Not a common enough pattern to support |
TypeScript Version:
1.9.0-dev
Code
The text was updated successfully, but these errors were encountered: