-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
If the user defines a type guard for a boolean, as in this example:
function isBool(a: any): a is boolean {
return (typeof a === "boolean");
}
function bob() {
var z;
if (isBool(z)) {
z; // type of z is still 'any'
}
}...then z is not properly refined to 'boolean'. It stays 'any'. I think the expected behavior here is for the type guard to refine to boolean inside of the if check.
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript