This project is read-only.

Computed enum members

Topics: Language Specification
Nov 25, 2013 at 12:37 PM
Consider the following code:
   export enum MyEnum {
        B = Arrrr
TypeScript compiler gives me no error, but I can't find anything about ability to reference constant enum members from computed enum members without qualification. There is no mention about it in 2.4 (scopes where names could be used without qualification), there is no mention about it in 9 (Enums). On the opposite, code samples in specs use qualified names. So, is this a bug in specs or in compiler? Is there any other cases where name could be used without qualifications that are not mentioned in 2.4? Thanks!
Nov 25, 2013 at 4:20 PM
The spec defines this behavior in sections 2.3 and 2.4:

• Each enum declaration has a declaration space for its enum members. An enum’s declaration space is shared with other enums that have the same root module and the same qualified name starting from that root module.
• The scope of a member declared in an enum declaration is the body of that declaration and every enum declaration with the same root and the same qualified name relative to that root.
Nov 25, 2013 at 4:33 PM
This text is absent from 2.4 in . Time to upload 0.9.5 version there?
Nov 25, 2013 at 5:11 PM
We usually update that with each official release, so that should get changed soon once 0.9.5 is released. I'm working from the copy checked in to \doc\ in the develop branch, which is more current.