2014-07-13 01:04:16 +02:00
|
|
|
//// [switchCasesExpressionTypeMismatch.ts]
|
|
|
|
class Foo { }
|
|
|
|
|
|
|
|
switch (0) {
|
|
|
|
case Foo: break; // Error
|
|
|
|
case "sss": break; // Error
|
|
|
|
case 123: break; // No Error
|
|
|
|
case true: break; // Error
|
|
|
|
}
|
|
|
|
|
|
|
|
var s: any = 0;
|
|
|
|
|
|
|
|
// No error for all
|
|
|
|
switch (s) {
|
|
|
|
case Foo: break;
|
|
|
|
case "sss": break;
|
|
|
|
case 123: break;
|
|
|
|
case true: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//// [switchCasesExpressionTypeMismatch.js]
|
|
|
|
var Foo = (function () {
|
|
|
|
function Foo() {
|
|
|
|
}
|
|
|
|
return Foo;
|
|
|
|
})();
|
|
|
|
switch (0) {
|
2014-11-04 02:15:14 +01:00
|
|
|
case Foo: break;
|
|
|
|
case "sss": break;
|
|
|
|
case 123: break;
|
|
|
|
case true: break;
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
var s = 0;
|
|
|
|
switch (s) {
|
2014-11-04 02:15:14 +01:00
|
|
|
case Foo: break;
|
|
|
|
case "sss": break;
|
|
|
|
case 123: break;
|
|
|
|
case true: break;
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|