-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
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).
djcsdy and zhibirc
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript