From 72f1789ad87fbc0feb2ba0835088ffc0b05897fd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:31:18 -0700 Subject: [PATCH] Revert PR 56161 --- 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 0c5af109e5b32..41908c157877b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -45689,7 +45689,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