-
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
Wrong type narrowing when types are compatibles #11664
Labels
Fixed
A PR has been merged for this issue
Milestone
Comments
Indeed, this is a duplicate :( |
FYI- This still reproduces with TypeScript 2.3.2 |
Really simplistic example of what's wrong with instanceof: const model = this.opts.resources.model.store.get(id);
if (!model || model instanceof Placeholder)
return null;
const data: any = model.get(); TSC gives the following error: A workaround was proposed in #13325 but I can't see an equivalent in imperative code sections. |
Fixed in #19671 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypeScript Version: 2.0.3
Code
Expected behavior:
instance of type guard should not care about type compatibility
Actual behavior:
Wrong assertion by the compiler.
The text was updated successfully, but these errors were encountered: