Microsoft/TypeScript

Enum value `1 / 0` incorrectly transformed if there is `Infinity` declared in scope

Open

#55.091 geöffnet am 20. Juli 2023

Auf GitHub ansehen
 (3 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: enumFix AvailableHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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 https://github.com/microsoft/TypeScript/issues/54981.

Contributor Guide