-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 3.0.0
Search Terms: unknown, object, narrow type
Code
const input = null as unknown
if (typeof input === 'number') {
input
// input is typed as number here, good!
}
if (typeof input === 'object') {
input
// input is typed as unknown here, why not object?
}
Expected behavior:
Expected an unknown type inside a typeof _ === 'object'
guard to be of type object.
Actual behavior:
The type stays as unknown
Related Issues:
#25720
This was mentioned in the comments here: #25720 (comment), but I couldn't find a standalone issue for it. Thus I created this issue to get more visibility.
ThomasdenH, jamesmbourne and Finesse
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue