Skip to content

All enums should be const #1408

@Tyriar

Description

@Tyriar

There's a big difference in the compiled output, we never want the enums to change we they should be const.

enum a {
	b,
	c,
	d
}

const enum A2 {
	B2,
	B3,
	B4
}

console.log(a.b);
console.log(A2.B2);

Compiles to:

var a;
(function (a) {
    a[a["b"] = 0] = "b";
    a[a["c"] = 1] = "c";
    a[a["d"] = 2] = "d";
})(a || (a = {}));
console.log(a.b);
console.log(0 /* B2 */);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions