TypeScript/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt

25 lines
700 B
Plaintext
Raw Normal View History

2014-07-13 01:04:16 +02:00
==== tests/cases/compiler/switchCasesExpressionTypeMismatch.ts (3 errors) ====
class Foo { }
switch (0) {
case Foo: break; // Error
~~~
!!! Type 'typeof Foo' is not assignable to type 'number'.
case "sss": break; // Error
~~~~~
!!! Type 'string' is not assignable to type 'number'.
case 123: break; // No Error
case true: break; // Error
~~~~
!!! 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;
}