You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This condition will always return 'false' since the types '"b"' and '"a"' have no overlap.(2367)
...but the value might be "a". The condition might not return false. It's worth looking at the code snippets below, as I think they describe the issue better.
🔎 Search Terms
TS2367
Condition always returns false
Value changes during await
🕗 Version & Regression Information
This does not seem to be a recent regression. When I test in the playground, I see this problem in all v4 versions.
letstate: 'a'|'b'='a';asyncfunctiona(){state='b';awaitPromise.resolve();// The following line has an error that I think should not happen:if(state==='a'){thrownewError('hello');}}a()state='a';
Here's another example that I think better isolates the issue:
letstate: 'a'|'b'='a';asyncfunctiona(){state='b';awaitPromise.resolve();constnewState: 'a'|'b'=state;console.log(newState);// <- type seems incorrect here}a()state='a';
🙁 Actual behavior
Got TS2367.
🙂 Expected behavior
There is no error.
The text was updated successfully, but these errors were encountered:
Bug Report
I'm receiving the following error...
...but the value might be
"a"
. The condition might not returnfalse
. It's worth looking at the code snippets below, as I think they describe the issue better.🔎 Search Terms
await
🕗 Version & Regression Information
This does not seem to be a recent regression. When I test in the playground, I see this problem in all v4 versions.
⏯ Playground Link
Playground link with relevant code
💻 Code
Here's another example that I think better isolates the issue:
🙁 Actual behavior
Got TS2367.
🙂 Expected behavior
There is no error.
The text was updated successfully, but these errors were encountered: