Open DanielRosenwasser opened 6 months ago
Last section is about https://github.com/microsoft/TypeScript/pull/57847 :)
Thanks for catching that! Updated
The discussion about enum reverse mappings reads like an account of a game of tug-of-war, and then at the end nobody wins - the rope goes slack and both teams fall in the mud 😝
Preserving attributes on reference directives
https://github.com/microsoft/TypeScript/pull/57681
preserve="true"
?.d.ts
bundlers?.d.ts
and get the same behavior.Reallowing
Infinity
,-Infinity
,NaN
as enum member namesBackground
https://github.com/microsoft/TypeScript/pull/56161 https://github.com/microsoft/TypeScript/issues/57845
enum E { "10" = 42 }
enum E { "10" = 42, yadda = 10 }
which breaks the reverse mapping.E[10]
maps toyadda
not42
Infinity
orNaN
enum E { Infinity = 1, yadda = 1/0 }
.Infinity
, what's the problem?Proposal
Discussion
enum E { yadda = 'yadda' }
had a reverse mapping, it would overwrite the reverse mapping. AndRed = 'Red'
is super common.Narrowing element accesses with non-constant expressions
https://github.com/microsoft/TypeScript/pull/57847
obj[key]
and you change neitherobj
norkey
, the type system really should understand that!key
was often a parameter, or varied within a loop variable.let
variables that don't actually mutate (and captured variables that don't mutate after a certain point).Not everything "lights up" the way you'd think.
obj
to be indexable.obj
to have the typeobject & Record<unique typeof key, unknown>
. Really wouldn't wantobj
to be indexable with allstring
s, justkey
itself.key
.