[proposal] Non widened string values should be valid enum values, like widened string values #59346
Open
6 tasks done
Labels
Milestone
π Search Terms
enum, string
β Viability Checklist
β Suggestion
TypeScript accepts widened strings as enum values, but refuses to accept non widened strings as enum values. I propose to relax this constraint allowing widened and non widened strings as valid enum values.
π Motivating Example
At the moment TypeScript accepts widened strings as valid enum values.
Trying to use a non widened string results in a compiler error.
π» Use Cases
Given a consumer project
P1
using exported widened strings values from a consumed libraryL1
, ifL1
annotates the exported strings valuesas const
,L1
breaksP1
.Given that a widened string value is a valid enum value, a "stricter" non widened string (a subset of the widened one) should be a valid enum value too.
The text was updated successfully, but these errors were encountered: