🤖 Pick PR #57853 (Revert PR 56161) into release-5.4 (#57854)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
TypeScript Bot 2024-03-19 15:07:36 -07:00 committed by GitHub
parent ca8e720a36
commit cd06f92c43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1 additions and 31 deletions

View File

@ -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);
}
}

View File

@ -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.
}

View File

@ -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.
}

View File

@ -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.
}