| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) pack this |
Sorry, something went wrong.
|
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the tarball bundle task on this PR at 50a952b. You can monitor the build here. |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test this |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 50a952b. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 50a952b. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 50a952b. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 50a952b. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) Comparison Report - main..50528
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) Here are the results of running the user test suite comparing main and refs/pull/50528/merge: Everything looks good! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
Sorry, something went wrong.
|
Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so: {
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/133037/artifacts?artifactName=tgz&fileId=3F948668C1BD8758CB1C8E59919B3D6E945DCF3815094A729B98FCE15A366B7E02&fileName=/typescript-4.9.0-insiders.20220829.tgz"
}
}
and then running npm install. There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.9.0-pr-50528-10".; |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test this |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based top-repos suite on this PR at 3f66f6c. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 3f66f6c. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 3f66f6c. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 3f66f6c. You can monitor the build here. |
Sorry, something went wrong.
|
Is this included in a published version of Typescript yet? Based on the comments in this PR thread, it sounds like it should be in Typescript 5. I'm on Typescript 5.0.2, but getting the error "const enum member initializers can only contain literal values and other computed enum values.", which I believe shouldn't happen if I'm on a version of typescript that includes this code? I'm copying the example from the PR: const prefix = '/data';
const enum Routes {
Parts = `${prefix}/parts`, // "/data/parts"
Invoices = `${prefix}/invoices`, // "/data/invoices"
}
|
Sorry, something went wrong.
Alex von Brandenfels (@Sweater-Baron) Yes it is, your example is working perfectly fine running version 5.0.2 (see playground). If you use VSCode make sure that you use your local TypeScript version and not VSCode's version. |
Sorry, something went wrong.
|
Is there any plan to implement enum extension like in this playground (or some other way to extend enums)?: |
Sorry, something went wrong.
I have set my vscode to use 5.0.2, but im still getting the error |
Sorry, something went wrong.
|
Jordan Christiansen (@JordanDC2) Not 100% exactly what you asked for.. |
Sorry, something went wrong.
|
Colin Richardson (@WORMSS) yeah thats kind of what im having to work with currently, i just wish it was a capability of Enums since we can have computed values now but not computed keys |
Sorry, something went wrong.
Man, you saved me, thank you. |
Sorry, something went wrong.
|
Sounds weird, but I'm on Typescript 5.0.2. I'm forcing VSC to use the local installed Typescript version (which it recognizes is 5.0.2 instead of VSC's 4.9.5) and the enum values still get udnerlined with red squiggly line. export enum TABLES {
foo = `${config.schema}.foos`,
bar = `${config.schema}.bars`
}
Any ideas what I'm missing here? I see the playground link posted above by Jan R. Biasi (@janbiasi) and it should be working for 5.0.2. But it's not. I confirm that the project has 5.0.2 installed with npm ls typescript; only 5.0.2 and no other version exists in the workspace. |
Sorry, something went wrong.
|
We just tried to update our code base and we noticed a ton of errors. Turns out this change basically means you cannot treat an enum as basically "just" a number anymore? No way to optionally tell TypeScript to allow "optional" values that are basically null? This is somewhat weird, because you now can't have a fall back state and HAVE to define a "NONE" type. enum TEST {
ONE = 1,
TWO
}
const foo: TEST = 0;
This now is an error. Was there any reason not to allow for a fallback here? |
Sorry, something went wrong.
|
how come would be really useful to not have this not so obvious difference you can check some examples here |
Sorry, something went wrong.
|
Gabriel-Calin Lazar (@gabriel-calin-lazar) See my comment here. |
Sorry, something went wrong.
|
tka85 any ideas about it? Also have TS above 5 and it complains |
Sorry, something went wrong.
|
Valery Tarelkin (@vtarelkin) Nope. No response. |
Sorry, something went wrong.
|
An old PR is really not the best place to ask for help or report bugs. I would really suggest filing an issue if you want it to be seen by the right people. |
Sorry, something went wrong.
|
Jake Bailey (@jakebailey) people are searching over the whole net and hope to find a clue here) maybe you could help us please?)) I have a TS above 5th version and it still complains |
Sorry, something went wrong.
|
Please, please, please, file an issue and fill out the template. |
Sorry, something went wrong.
|
Jake Bailey (@jakebailey) this issues comes the first google search result. I have typescript 5.1.3 and just noticed the same problem, still trying to find any relevant tickets in this repo. If there is a solution - it might be helpful to add it here, or at least have a link somewhere in comments |
Sorry, something went wrong.
|
Please file a new issue outlining the problem you're having |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Since #9407 TypeScript has had two kinds of enum types: Numeric enum types and literal enum types (also known as union enum types). Numeric enum types have permitted enum members to have computed values, but not literal types; whereas literal enum types have required members to be declared using simple numeric or string literals only. The distinction between these two kinds of enums is subtle and has been the source of a fair amount of confusion over time.
With this PR we unify the two kinds into a single hybrid that incorporates the best of both worlds. Specifically, enums are always represented as unions of their member types, member values may be computed by constant or non-constant expressions, and members with constant values are given literal types. The PR only affects type checking of enums. There are no changes to the emitted code (except for better inlining of constant expressions in some cases).
An enum declaration now declares a type representing the entire enum and types representing each member (similar to literal enum types). For example,
declares a type E and types E.A, E.B, and E.C, where E is the union E.A | E.B | E.C.
An enum member has a literal enum type when it is initialized by a constant expression or when it has no initializer and is given an auto-incremented numeric value. In the example above, E.A and E.B denote enum literal types with values 100 and "foo" respectively.
An enum member has a unique and opaque enum member type when it is initialized by a non-constant expression. Non-constant initializer expressions must be assignable to type number and are not permitted in const enum declarations. In the example above, E.C denotes a unique enum member type representing the value computed by the non-constant initializer expression. This unique type is assignable to type number, but otherwise incompatible with other types.
An expression is considered a constant expression if it is
Note that constant expressions are not permitted to make forward references--any value referenced by a constant expression must have been previously declared.
Some examples:
NOTE: This PR is technically a breaking change because checking of the new unified enum types is stricter than the old numeric enum types.
Fixes #27976.
Fixes #35875.
Fixes #40793.
Fixes #43902.