-
Notifications
You must be signed in to change notification settings - Fork 12.8k
instanceof Promise in ternary does not narrow Promiselike in 4.1 #41606
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
Did you mean to use |
Ah yeah. I was wondering why the bug is only on the new version and I couldn’t reproduce the old behavior. Fixed the typescript example so it only fails on 4.1. |
I think this cooould be an instance of #41563. It’s essentially an overload selection problem—the intersected |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @brainkim 👍 Compiled Historical Information
|
It seems that this have been already fixed in 4.2.2 and issue could be closed? |
@rubiesonthesky This appears to have been fixed since 4.2.2. Thanks. |
TypeScript Version: 4.1.0-beta
Search Terms:
promise promiselike instanceof
Code
Expected behavior:
No errors.
Actual behavior:
p2 errors because the expression has been determined to be promise-like.
Also p1 is inferred as PromiseLike & Promise.
Playground Link:
https://www.typescriptlang.org/play?ts=4.1.0-beta#code/CYUwxgNghgTiAEYD2A7AzgF3gBwFzwAUYkBbASzRABkyBrEAHhQFcSAjEGAPgG4AoZOizYAjPAC8OeGSFQUYEEgBmhYuUrwA-FPxFSFEADo4aJBABuIABTYAlP0GYcAJl1qDTVh24ScIwxgAFiAoVlbmthJc8ObwANTwIvZAA
Related Issues:
The text was updated successfully, but these errors were encountered: