Comments (5)
It's not about whether or not you can write TestEnum.Foo
(e.g. "Foo Bar" = "works"
is also legal) but whether the name of a member could potentially clash with a reverse mapping, so keys that overlap with the canonical string representation of a number are intentionally not allowed.
from typescript.
Oh okay! Thank you for the information, and sorry for the wrong assumption and the disturbance :D
from typescript.
This isn't a bug: all of the following are intentionally allowed:
enum TestEnum {
"1e2",
"3.40",
".567",
"88888888888888888"
}
It's for the reason @fatcerberus said; while those can be parsed as numbers, they are not how those numbers would be represented when converted to strings, so they cannot conflict with reverse mappings. If there were no reverse mappings, all numeric keys would be allowed.
from typescript.
Bracket notation is still valid: TestEnum["00"]
from typescript.
Yeah, but in that sense TestEnum["0"]
would also be valid.
from typescript.
Related Issues (20)
- [NewErrors] 5.5.0-dev.20240519 vs 5.4.5 HOT 59
- [ServerErrors][TypeScript] undefined HOT 4
- Optional parameters instantiated from generic params add `| undefined` to the type HOT 11
- [ServerErrors][JavaScript] 5.5.0-dev.20240519 HOT 3
- Function parameters are not inferable when defined via JSDoc using @type tag (with strict) HOT 5
- Reachability analysis of `never` for `yield*` is unchecked HOT 1
- Declaration emit not dropping untyped computed property name
- `getTextOfJSDocComment` introduces a space in JSDoc comments
- Typescript Stickers HOT 6
- Bloomberg TS5.5-beta feedback [part two] HOT 1
- FEATURE REQUEST: For TypeScript / JS add new refactor feature: if class method can be static add tooltip "make method static" HOT 2
- Incorrect type handing/reduction HOT 3
- [transpileDeclaration API][5.5] Self referencing generic type constraint with union gets emitted as `unknown`
- Syntax highlighting can not resolve @throws of tsdoc HOT 3
- tsc crash with `Error: start < 0` in a specific config HOT 1
- computeCommonSourceDirectory doesn't work with subst on windows
- Type union not matched starting from TS 5.1 HOT 3
- union with `any` shows as union in signature quickinfo but `any` in parameter quickinfo HOT 5
- Add strictFunctionTypes to Enhance Type Safety for Function Parameters HOT 3
- Methods of classes extended in others do not inherit the types of method arguments. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.