Skip to content

Ability to disable TS enum value inlining? #8114

@dsherret

Description

@dsherret

Describe the feature

Given the following code:

enum D {
  A,
  B,
}

(D as any).A = 5;
console.log(D.A);

swc 1.3.88 outputs 5 and 1.3.89 outputs 0. This is because swc started inlining enums within a module.

var D;
(function(D) {
    D[D["A"] = 0] = "A";
    D[D["B"] = 1] = "B";
})(D || (D = {}));
D.A = 5;
console.log(0);

Is there a way to disable this optimization? Although unlikely, I'm concerned it might cause bugs in people's Deno code since it would be a breaking change.

Babel plugin or link to the feature description

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions