We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
--strictNullChecks
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'); }
TypeScript Version:
nightly (1.9.0-dev.20160604-1.0)
Code
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: