Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Omit enum reverse lookup code in TS. #1454

Open
mbebenita opened this issue Apr 24, 2015 · 3 comments
Open

Omit enum reverse lookup code in TS. #1454

mbebenita opened this issue Apr 24, 2015 · 3 comments

Comments

@mbebenita
Copy link
Contributor

TS emits a bit of extra code for enum definitions. For instance:

enum A {
    x, y, z
}

var a = A.x;

is compiled to:

var A;
(function (A) {
    A[A["x"] = 0] = "x";
    A[A["y"] = 1] = "y";
    A[A["z"] = 2] = "z";
})(A || (A = {}));
var a = 0 /* x */;

We don't really need to do reverse lookups on enums. Perhaps we could add a compiler option to the TS compiler that omits this code.

@marco-c
Copy link
Contributor

marco-c commented Apr 24, 2015

Should we file an issue in the TypeScript repo to ask them to add this option?

@mbebenita
Copy link
Contributor Author

@marco-c
Copy link
Contributor

marco-c commented Apr 29, 2015

In some cases we might simply use const enum

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants