-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
unknownin switch at clause"function"should result in typeFunction. - Narrowing
unknownin switch at clause"object"should result in typeobject | null.
Actual behavior:
- Value of type
unknowndoes 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