Open
Description
Bug Report
π Search Terms
literal widening typeof
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries
β― Playground Link
Playground link with relevant code
π» Code
const foo = "fooey"; // widening
let id1 = foo; // widening
let id2 = foo as typeof foo; // non-widening
id1 = "hello" // ok
id2 = "hello" // type error
π Actual behavior
Assigning to id2
gives a type error, while assigning the same thing to id1
does not.
π Expected behavior
There should be absolutely no difference between id1
and id2
, because foo as typeof foo
should be an identity cast/no-op.