30 lines
No EOL
1.1 KiB
Text
30 lines
No EOL
1.1 KiB
Text
tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(4,10): error TS2322: Type 'typeof Foo' is not assignable to type 'number'.
|
|
tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(5,10): error TS2322: Type 'string' is not assignable to type 'number'.
|
|
tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(7,10): error TS2322: Type 'boolean' is not assignable to type 'number'.
|
|
|
|
|
|
==== tests/cases/compiler/switchCasesExpressionTypeMismatch.ts (3 errors) ====
|
|
class Foo { }
|
|
|
|
switch (0) {
|
|
case Foo: break; // Error
|
|
~~~
|
|
!!! error TS2322: Type 'typeof Foo' is not assignable to type 'number'.
|
|
case "sss": break; // Error
|
|
~~~~~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
case 123: break; // No Error
|
|
case true: break; // Error
|
|
~~~~
|
|
!!! error TS2322: 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;
|
|
} |