TypeScript/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt
2014-09-11 16:11:08 -07:00

25 lines
742 B
Plaintext

==== tests/cases/compiler/switchCasesExpressionTypeMismatch.ts (3 errors) ====
class Foo { }
switch (0) {
case Foo: break; // Error
~~~
!!! error TS2323: Type 'typeof Foo' is not assignable to type 'number'.
case "sss": break; // Error
~~~~~
!!! error TS2323: Type 'string' is not assignable to type 'number'.
case 123: break; // No Error
case true: break; // Error
~~~~
!!! error TS2323: Type 'boolean' is not assignable to type 'number'.
}
var s: any = 0;
// No error for all
switch (s) {
case Foo: break;
case "sss": break;
case 123: break;
case true: break;
}