Closed
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