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
functionwait(tm: number){returnnewPromise((resolve,reject)=>{setTimeout(()=>resolve(true),tm);});}letx: "foo"|"bar";asyncfunctionbaz(){x="bar";awaitwait(1000);if(x=="foo"){// erroneous: This condition will always return 'false' since the types '"bar"' and '"foo"' have no overlap.console.log("could be reached");}}setTimeout(()=>x="foo",500);baz();
Expected behavior:
Code should compile fine
Actual behavior:
Compiler believes x must be "bar" since it was assigned such at the start of the method. However since there is an await this is not true.
Ah I had seen that issue but didn't read the comments in enough detail. In particular this issue is exactly what was written up in this comment: #9998 (comment)
TypeScript Version: 3.4.0
Search Terms: enumeration async await
Code
Expected behavior:
Code should compile fine
Actual behavior:
Compiler believes x must be "bar" since it was assigned such at the start of the method. However since there is an await this is not true.
Playground Link:
Playground link
Related Issues:
The text was updated successfully, but these errors were encountered: