Closed
Description
TypeScript Version: master 83fe1ea
Search Terms: switch typeof unknown
Code
// @strictNullChecks: true
function unknownNarrowing(x: unknown) {
switch (typeof x) {
case 'function': x; return; // x is unknown, should be Function
case 'object': x; return; // x is unknown, should be object | null
}
}
Expected behavior:
- Narrowing
unknown
in switch at clause"function"
should result in typeFunction
. - Narrowing
unknown
in switch at clause"object"
should result in typeobject | null
.
Actual behavior:
- Value of type
unknown
does not narrow.
Playground Link: N/A (Playground not on this version).