Closed
Description
TypeScript Version:
nightly (1.9.0-dev.20160217)
Code
let greeting:string;
let x = (message: string | number) => {
if (typeof message !== "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.