-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue