-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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.20160604-1.0)
Code
let foo:number|null = 0;
switch(foo) {
case null:
break;
case 0:
console.log('bar');
}
Expected behavior:
Null check should be allowed
Actual behavior:
Compiler complains "TypeScript Type 'null' is not comparable to type 'number'. (TS2678)"
Note:
If I add an 'if' condition before the switch, the compiler does not complain about either the 'if' or the switch. For instance:
let foo:number|null = 0;
if (foo === null) { console.log('bar'); }
switch(foo) {
case null:
break;
case 0:
console.log('bar');
}
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