From 98ac4e4c51a0b7b8f75d5f854a3f890be9851573 Mon Sep 17 00:00:00 2001 From: Fabian Cook Date: Thu, 8 Sep 2016 09:21:34 +1200 Subject: [PATCH] Allow -Infinity as an enum property name --- src/compiler/checker.ts | 2 +- .../reference/enumWithNegativeInfinityProperty.js | 11 +++++++++++ .../enumWithNegativeInfinityProperty.symbols | 7 +++++++ .../reference/enumWithNegativeInfinityProperty.types | 8 ++++++++ .../compiler/enumWithNegativeInfinityProperty.ts | 3 +++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/enumWithNegativeInfinityProperty.js create mode 100644 tests/baselines/reference/enumWithNegativeInfinityProperty.symbols create mode 100644 tests/baselines/reference/enumWithNegativeInfinityProperty.types create mode 100644 tests/cases/compiler/enumWithNegativeInfinityProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3910d658edf..e2377db8f31 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10034,7 +10034,7 @@ namespace ts { } function isInfinityOrNaNString(name: string) : boolean { - return name === 'Infinity' || name === 'NaN'; + return name === 'Infinity' || name === '-Infinity' || name === 'NaN'; } function isNumericLiteralName(name: string) { diff --git a/tests/baselines/reference/enumWithNegativeInfinityProperty.js b/tests/baselines/reference/enumWithNegativeInfinityProperty.js new file mode 100644 index 00000000000..867545fb14a --- /dev/null +++ b/tests/baselines/reference/enumWithNegativeInfinityProperty.js @@ -0,0 +1,11 @@ +//// [enumWithNegativeInfinityProperty.ts] +enum A { + "-Infinity" = 1 +} + + +//// [enumWithNegativeInfinityProperty.js] +var A; +(function (A) { + A[A["-Infinity"] = 1] = "-Infinity"; +})(A || (A = {})); diff --git a/tests/baselines/reference/enumWithNegativeInfinityProperty.symbols b/tests/baselines/reference/enumWithNegativeInfinityProperty.symbols new file mode 100644 index 00000000000..51c61196ca6 --- /dev/null +++ b/tests/baselines/reference/enumWithNegativeInfinityProperty.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/enumWithNegativeInfinityProperty.ts === +enum A { +>A : Symbol(A, Decl(enumWithNegativeInfinityProperty.ts, 0, 0)) + + "-Infinity" = 1 +} + diff --git a/tests/baselines/reference/enumWithNegativeInfinityProperty.types b/tests/baselines/reference/enumWithNegativeInfinityProperty.types new file mode 100644 index 00000000000..bc09333075d --- /dev/null +++ b/tests/baselines/reference/enumWithNegativeInfinityProperty.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/enumWithNegativeInfinityProperty.ts === +enum A { +>A : A + + "-Infinity" = 1 +>1 : number +} + diff --git a/tests/cases/compiler/enumWithNegativeInfinityProperty.ts b/tests/cases/compiler/enumWithNegativeInfinityProperty.ts new file mode 100644 index 00000000000..057c3a5e669 --- /dev/null +++ b/tests/cases/compiler/enumWithNegativeInfinityProperty.ts @@ -0,0 +1,3 @@ +enum A { + "-Infinity" = 1 +}