-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Bug: Control flow type analysis regression. #11153
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
This is working as intended. The problem here is that structurally That said, this is not the first time someone has reported this issue. In the particular case of |
@ahejlsberg Why then this code compiles fine: class A { constructor(public b: number) {} }
class B { constructor(public b: number) {} }
function foo(x: A | B): number | boolean {
if (x instanceof A) { return true; }
else if (x instanceof B) { return x.b; }
}; ? Also, as I said this worked fine in Typescript 1.8 and it isn't mentioned in Breaking Changes page. |
Sorry, I missed the There are more details on the changes since 1.8 in #10194 and #10216. The core issue we have is that we use structural subtype relationships to reason about |
TypeScript Version: 2.0.3
This code compiles in TS 1.8 but not in 2.0.3
Code
This error only appears if class
A
has no fields or methods,if I add a field or a method the error disappears (but not constructor).
The text was updated successfully, but these errors were encountered: