Closed osdm closed 9 years ago
I believe that technically, this isn't a bug, but it may prompt us to review the TypeScript spec. Perhaps @ahejlsberg, @JsonFreeman, or others can clarify.
3.7.4 Index Signatures
A _numerically named property_ is a property whose name is a valid numeric literal. Specifically, a property with a name N for which ToNumber(N) is not NaN, where ToNumber is the abstract operation defined in ECMAScript specification.
The definition should probably be tightened to only apply to properties x
such that ToString(ToNumber(x)) === x
. Similarly, names like 1e2
are not actually numerically-named for the purposes of runtime behavior.
Right, I remember discussing this with @RyanCavanaugh. The ecmaScript rules around this can get pretty weird, as 1e2
would not be the result of a ToString, but 1e25
can be.
Any reason this has the milestone of 2.0? This is a relatively minor spec change.
Agreed
@ahejlsberg, @osdm,
this bug is not reproducible in Version 1.5.0-beta (npm install typescript@1.5.0-beta
), fixed by #860.
Thanks @jasonwilliams200OK, right now this tracks the need to update the spec.
Fixed in #4033.
Quoted literal property names with leading or trailing spaces are treated as numeric property names, although they are not treated as numbers by JS.