You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Computed expressions on enum members would swap an enum over to a numeric enum, which preserves no information about the singleton types that each member represents.
Meant you would get no control flow analysis on bindings who are assigned these enums.
PR changes numeric enums to still be literal-ish.
When enums are computed and we cannot follow the computation, we now create an "opaque enum member".
These are assignable to number and and the containing enum, but nothing becomes assignable to it.
Enums that contain these numeric members still allow assignments from any other number to support the bitflags case.
PR also allows
concatenation from template string expressions.
references to literal-initialized const variables.
Most people are just using union enums. Not a huge performance effect. Things in our perf suite were not affected. Identified one questionable issue in VS Code. 4 new errors in our compiler. One is Trade-offs in Control Flow Analysis #9998.
Doing more in the enum space feels iffy - is runtime behavior, but is runtime behavior that TypeScript already kind of has made.
Some things in the pipeline for ECMAScript... though that proposal would be radically different anyway.
Our enums have relatively little value for JS users - it's the same as an object literal for the most part.
ES proposal does intend to keep some of TS behavior.
"Scalar enums"
We don't feel good treading this ground even if TypeScript has set a lot of precedent - lots of occasions where the "simple obvious" language feature has issues with what actually lands in ECMAScript.
The text was updated successfully, but these errors were encountered:
Codebase Module Migration
#49332
Debug
into a namespace.let
/const
- we're not going to bother downleveling that at the moment becauseconst
starget
?es2015
is safest, but is already kind of old.es2016
has**
, but not a huge pulles2017
hasasync
/await
- we don't use it reallyes2018
has async generators - but same as above..d.ts
?Auto-imports will keep tacking imports and mess with the line length.
Also, most import lists are on one line...
or multiple imports per line
but
checker.ts
has a CRAZY number of imports, and we've done a mix to avoid the worst of both (long line length vs. thousands of import lines)So what do we want to do?
Could put them at the bottom.
Maybe it's time to break parts of
checker.ts
out.Let's do nothing for now.
Map
types?Map
s andReadonlyMap
?Enums Unifications and Improvements
#50528
Computed expressions on enum members would swap an enum over to a numeric enum, which preserves no information about the singleton types that each member represents.
PR changes numeric enums to still be literal-ish.
number
and and the containing enum, but nothing becomes assignable to it.Enums that contain these numeric members still allow assignments from any other number to support the bitflags case.
PR also allows
const
variables.Most people are just using union enums. Not a huge performance effect. Things in our perf suite were not affected. Identified one questionable issue in VS Code. 4 new errors in our compiler. One is Trade-offs in Control Flow Analysis #9998.
Aside - lots of cases where people want to extend enums (Extending string-based enums #17592)
The text was updated successfully, but these errors were encountered: