-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 3.0.0-dev.20180623
Search Terms: typescript unknown equality guard
Code
let x: unknown; // reproduces with const too
if (x === 5) {
let y = x.toString(10);
}
Expected behavior:
x
inside of the if
block to be of type 5
, y
to get type of string
, everyone happy.
Actual behavior:
x
inside of the if
block is still of type unknown
, I get an error for x
being of type unknown
and therefore does not have a property toString
.
Playground Link: N/A (dev build)
Related Issues: #24439
olaf89, SlurpTheo, jraoult and thw0rted
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript