Skip to content

Enum value 1 / 0 incorrectly transformed if there is Infinity declared in scopeΒ #55091

@nicolo-ribaudo

Description

@nicolo-ribaudo

Bug Report

πŸ”Ž Search Terms

infinity enum variable let shadow

πŸ•— Version & Regression Information

Every version I tested

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

{
  let Infinity = 3;

  enum A {
    X = 1 / 0
  }

  console.log(A.X)
}

πŸ™ Actual behavior

{
    let Infinity = 3;
    let A;
    (function (A) {
        A[A["X"] = Infinity] = "X";
    })(A || (A = {}));
    console.log(A.X);
}

and logs 3

πŸ™‚ Expected behavior

It should log the result of 1 / 0, which is Infinity.

Somewhat related to #54981.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: enumEnums and their associated types/valuesHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions