Skip to content

Assignment of string literal indexed enum member passes compilation but results in invalid javascript #2215

@joelmdev

Description

@joelmdev

The following TypeScript:

const enum MyEnum {This,That};
MyEnum["That"] = 1;

compiles down to the following javascript:

;
1 /* "That" */ = 1;

This holds true for standard enums as well, a const enum was just a more succinct example.
While I'm not sure why anyone would want to do this, it does seem that valid TypeScript should compile to valid javascript, and this will obviously cause a runtime error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions