From cd06f92c43eede05731cc0592bcb4ee7fe4d38cc Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 19 Mar 2024 15:07:36 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#57853=20(Revert=20P?= =?UTF-8?q?R=2056161)=20into=20release-5.4=20(#57854)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- src/compiler/checker.ts | 2 +- .../reference/enumWithInfinityProperty.errors.txt | 10 ---------- .../baselines/reference/enumWithNaNProperty.errors.txt | 10 ---------- .../enumWithNegativeInfinityProperty.errors.txt | 10 ---------- 4 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 tests/baselines/reference/enumWithInfinityProperty.errors.txt delete mode 100644 tests/baselines/reference/enumWithNaNProperty.errors.txt delete mode 100644 tests/baselines/reference/enumWithNegativeInfinityProperty.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 71dc5a4e83c67..3fef78b1df9fb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -45377,7 +45377,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else { const text = getTextOfPropertyName(member.name); - if (isNumericLiteralName(text)) { + if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name); } } diff --git a/tests/baselines/reference/enumWithInfinityProperty.errors.txt b/tests/baselines/reference/enumWithInfinityProperty.errors.txt deleted file mode 100644 index 27de0a69b0383..0000000000000 --- a/tests/baselines/reference/enumWithInfinityProperty.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -enumWithInfinityProperty.ts(2,5): error TS2452: An enum member cannot have a numeric name. - - -==== enumWithInfinityProperty.ts (1 errors) ==== - enum A { - Infinity = 1 - ~~~~~~~~ -!!! error TS2452: An enum member cannot have a numeric name. - } - \ No newline at end of file diff --git a/tests/baselines/reference/enumWithNaNProperty.errors.txt b/tests/baselines/reference/enumWithNaNProperty.errors.txt deleted file mode 100644 index 941fa099eefe2..0000000000000 --- a/tests/baselines/reference/enumWithNaNProperty.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -enumWithNaNProperty.ts(2,5): error TS2452: An enum member cannot have a numeric name. - - -==== enumWithNaNProperty.ts (1 errors) ==== - enum A { - NaN = 1 - ~~~ -!!! error TS2452: An enum member cannot have a numeric name. - } - \ No newline at end of file diff --git a/tests/baselines/reference/enumWithNegativeInfinityProperty.errors.txt b/tests/baselines/reference/enumWithNegativeInfinityProperty.errors.txt deleted file mode 100644 index d9923989b8a3f..0000000000000 --- a/tests/baselines/reference/enumWithNegativeInfinityProperty.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -enumWithNegativeInfinityProperty.ts(2,5): error TS2452: An enum member cannot have a numeric name. - - -==== enumWithNegativeInfinityProperty.ts (1 errors) ==== - enum A { - "-Infinity" = 1 - ~~~~~~~~~~~ -!!! error TS2452: An enum member cannot have a numeric name. - } - \ No newline at end of file