Skip to content

transformer: incorrect enum value #3620

@Boshen

Description

@Boshen

babel enum/mix-references/input.ts

In:

var x = 10;

enum Foo {
    a = 10,
    b = a,
    c = b + x,
}

Current output:

var x = 10;
var Foo = function(Foo) {
	Foo[Foo['a'] = 10] = 'a';
	Foo[Foo['b'] = 10] = 'b';
	Foo[Foo['c'] = Foo.b + Foo.x] = 'c';
	return Foo;
}(Foo || {});

This produces an incorrect transform, Foo.x is undefined producing Foo.c = NaN

We should transform it correctly even we don't compute enum values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory - Bug

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions