TypeScript/tests/cases/compiler/unreachableSwitchTypeofUnknown.ts
Song 5484687384
switch typeof any could be checked for unreachable (#39389)
* switch typeof any could be checked for unreachable

* fix stupid error

* support unknown

* remvoe use less code.

* fix spelling.
2020-07-21 13:51:27 -04:00

15 lines
421 B
TypeScript

// @Filename: unreachable.ts
// @allowUnreachableCode: false
const unreachable = (x: unknown): number => {
switch (typeof x) {
case 'string': return 0
case 'number': return 0
case 'bigint': return 0
case 'boolean': return 0
case 'symbol': return 0
case 'undefined': return 0
case 'object': return 0
case 'function': return 0
}
x;
}