as const
does not narrow when object literal defined with type
#45287
Labels
Duplicate
An existing issue was already created
Bug Report
🔎 Search Terms
Searched:
🕗 Version & Regression Information
Example in playground
💻 Code
🙁 Actual behavior
Since foo is defined as
A
thetypeof
ignores theas const
andFooKeys
ends up beingstring | number
🙂 Expected behavior
I would expect foo being defined with
as const
would narrow to a type with onlya
andb
keys.So I would expect
FooKeys
to be"a" | "b"
Workaround
If this is not a bug
If this is actually expected, can this issue be transferred into a feature request?
The text was updated successfully, but these errors were encountered: