TypeScript Version: 3.7.2
Search Terms:
- "Promise"
await- reachability analysis
- control flow analysis
- definite assignment analysis
Code
(async()=>{letb: string;leta1=awaitPromise.reject();// returns Promise<never>b="";// Not unreachable?b.toUpperCase();// Not unreachable?})();Expected behavior:
As a1 is inferred to be never (e.g. behaves like in the non-promised version), I expected the rest of the code to be marked as unreachable aswell:
functionreturnNever(): never{thrownewError();}(async()=>{letb: string;leta0=returnNever();// a0 is neverb="";// Unreachableb.toUpperCase();// Unreachable})();Actual behavior:
The code after the never-returning promise is marked as reachable.
Related Question on StackOverflow: Has more code: https://stackoverflow.com/questions/58732814
Related Issue: #10973 (although marked as "Working as intended", it was changed later. 3.7.2 behaves like the issue opener expected).
If this is not a bug, what is the background for this behavior?
TypeScript Version: 3.7.2
Search Terms:
awaitCode
Expected behavior:
As
a1is inferred to benever(e.g. behaves like in the non-promised version), I expected the rest of the code to be marked as unreachable aswell:Actual behavior:
The code after the never-returning promise is marked as reachable.
Related Question on StackOverflow: Has more code: https://stackoverflow.com/questions/58732814
Related Issue: #10973 (although marked as "Working as intended", it was changed later. 3.7.2 behaves like the issue opener expected).
If this is not a bug, what is the background for this behavior?