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
letgreeting:string;letx=(message: string|number)=>{if(typeofmessage!=="string"){return;}// It's obvious, that message must be a string now. It works with "else statement" but not with early return.greeting=message;}}
Expected behavior:
No raising error.
Actual behavior:
Compiler raises an error that type string | number cannot be assigned to string variable.
The text was updated successfully, but these errors were encountered:
I tried this in 1.9.0-dev.20160429 (the latest nightly) and it does perform the analysis.
I believe version 1.9.0-dev.20160217 (a nightly build from 17th of February 2016) may not yet include control flow based type analysis, that was only merged on the 23 of April.
TypeScript Version:
nightly (1.9.0-dev.20160217)
Code
Expected behavior:
No raising error.
Actual behavior:
Compiler raises an error that type string | number cannot be assigned to string variable.
The text was updated successfully, but these errors were encountered: