From 57f931f6732cb43f4e52b7ee77e71731f8529fc5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:38:07 -0700 Subject: [PATCH 1/2] Add tests for infinite numeric literal emit --- .../constEnumInfinityShadow.errors.txt | 14 +++ .../compiler/constEnumInfinityShadow.js | 23 +++++ .../compiler/constEnumInfinityShadow.symbols | 19 +++++ .../compiler/constEnumInfinityShadow.types | 21 +++++ ...arationEmitNegativeNumericConstLiterals.js | 85 +++++++++++++++++++ ...onEmitNegativeNumericConstLiterals.symbols | 46 ++++++++++ ...tionEmitNegativeNumericConstLiterals.types | 67 +++++++++++++++ .../reference/compiler/fakeInfinity2.js | 16 ++++ .../reference/compiler/fakeInfinity2.symbols | 10 +++ .../reference/compiler/fakeInfinity2.types | 12 +++ .../cases/compiler/constEnumInfinityShadow.ts | 10 +++ ...arationEmitNegativeNumericConstLiterals.ts | 13 +++ .../tests/cases/compiler/fakeInfinity2.ts | 5 ++ 13 files changed, 341 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js create mode 100644 tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types create mode 100644 tsc/testdata/tests/cases/compiler/constEnumInfinityShadow.ts create mode 100644 tsc/testdata/tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.errors.txt b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.errors.txt new file mode 100644 index 0000000000000..e7ab177ecca97 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.errors.txt @@ -0,0 +1,14 @@ +constEnumInfinityShadow.ts(4,13): error TS2477: 'const' enum member initializer was evaluated to a non-finite value. + + +==== constEnumInfinityShadow.ts (1 errors) ==== + const Infinity = 0; + + const enum E { + value = 1e999, + ~~~~~ +!!! error TS2477: 'const' enum member initializer was evaluated to a non-finite value. + } + + export const value = E.value; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js new file mode 100644 index 0000000000000..a4946398f6887 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/constEnumInfinityShadow.ts] //// + +//// [constEnumInfinityShadow.ts] +const Infinity = 0; + +const enum E { + value = 1e999, +} + +export const value = E.value; + + +//// [constEnumInfinityShadow.js] +const Infinity = 0; +export const value = Infinity /* E.value */; + + +//// [constEnumInfinityShadow.d.ts] +declare const enum E { + value = Infinity +} +export declare const value = E.value; +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.symbols b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.symbols new file mode 100644 index 0000000000000..0266ee6b139a4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/constEnumInfinityShadow.ts] //// + +=== constEnumInfinityShadow.ts === +const Infinity = 0; +>Infinity : Symbol(Infinity, Decl(constEnumInfinityShadow.ts, 0, 5)) + +const enum E { +>E : Symbol(E, Decl(constEnumInfinityShadow.ts, 0, 19)) + + value = 1e999, +>value : Symbol(E.value, Decl(constEnumInfinityShadow.ts, 2, 14)) +} + +export const value = E.value; +>value : Symbol(value, Decl(constEnumInfinityShadow.ts, 6, 12)) +>E.value : Symbol(E.value, Decl(constEnumInfinityShadow.ts, 2, 14)) +>E : Symbol(E, Decl(constEnumInfinityShadow.ts, 0, 19)) +>value : Symbol(E.value, Decl(constEnumInfinityShadow.ts, 2, 14)) + diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types new file mode 100644 index 0000000000000..acb14e5a21a12 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/constEnumInfinityShadow.ts] //// + +=== constEnumInfinityShadow.ts === +const Infinity = 0; +>Infinity : 0 +>0 : 0 + +const enum E { +>E : E + + value = 1e999, +>value : E.value +>1e999 : Infinity +} + +export const value = E.value; +>value : E.value +>E.value : E +>E : typeof E +>value : E + diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js new file mode 100644 index 0000000000000..48f0eb43553b3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js @@ -0,0 +1,85 @@ +//// [tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts] //// + +//// [declarationEmitNegativeNumericConstLiterals.ts] +declare function id(value: T): T; + +export const a = -1e500 as const; +export const b = -123456789012345678901234567890 as const; +export const c = ((-1e500)) as const; +export const d = { value: -1e500 } as const; +export const e = [-1e500] as const; +export const f = id(-1e500); +export const g = -1e500; +export const h = 1e500; +export const i = { [-1e500]: 1 } as const; + + +//// [declarationEmitNegativeNumericConstLiterals.js] +export const a = -1e500; +export const b = -123456789012345678901234567890; +export const c = ((-1e500)); +export const d = { value: -1e500 }; +export const e = [-1e500]; +export const f = id(-1e500); +export const g = -1e500; +export const h = 1e500; +export const i = { [-1e500]: 1 }; + + +//// [declarationEmitNegativeNumericConstLiterals.d.ts] +export declare const a: -Infinity; +export declare const b: -1.2345678901234568e+29; +export declare const c: -Infinity; +export declare const d: { + readonly value: -Infinity; +}; +export declare const e: readonly [-Infinity]; +export declare const f: -Infinity; +export declare const g = -Infinity; +export declare const h = Infinity; +export declare const i: { + readonly [-Infinity]: 1; +}; + + +//// [DtsFileErrors] + + +declarationEmitNegativeNumericConstLiterals.d.ts(1,25): error TS1110: Type expected. +declarationEmitNegativeNumericConstLiterals.d.ts(3,25): error TS1110: Type expected. +declarationEmitNegativeNumericConstLiterals.d.ts(5,21): error TS1110: Type expected. +declarationEmitNegativeNumericConstLiterals.d.ts(6,1): error TS1128: Declaration or statement expected. +declarationEmitNegativeNumericConstLiterals.d.ts(7,35): error TS1110: Type expected. +declarationEmitNegativeNumericConstLiterals.d.ts(7,44): error TS1005: ';' expected. +declarationEmitNegativeNumericConstLiterals.d.ts(8,25): error TS1110: Type expected. + + +==== declarationEmitNegativeNumericConstLiterals.d.ts (7 errors) ==== + export declare const a: -Infinity; + ~ +!!! error TS1110: Type expected. + export declare const b: -1.2345678901234568e+29; + export declare const c: -Infinity; + ~ +!!! error TS1110: Type expected. + export declare const d: { + readonly value: -Infinity; + ~ +!!! error TS1110: Type expected. + }; + ~ +!!! error TS1128: Declaration or statement expected. + export declare const e: readonly [-Infinity]; + ~ +!!! error TS1110: Type expected. + ~ +!!! error TS1005: ';' expected. + export declare const f: -Infinity; + ~ +!!! error TS1110: Type expected. + export declare const g = -Infinity; + export declare const h = Infinity; + export declare const i: { + readonly [-Infinity]: 1; + }; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.symbols new file mode 100644 index 0000000000000..29ac7b881fc86 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.symbols @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts] //// + +=== declarationEmitNegativeNumericConstLiterals.ts === +declare function id(value: T): T; +>id : Symbol(id, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 20)) +>value : Symbol(value, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 29)) +>T : Symbol(T, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 20)) +>T : Symbol(T, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 20)) + +export const a = -1e500 as const; +>a : Symbol(a, Decl(declarationEmitNegativeNumericConstLiterals.ts, 2, 12)) +>const : Symbol(const) + +export const b = -123456789012345678901234567890 as const; +>b : Symbol(b, Decl(declarationEmitNegativeNumericConstLiterals.ts, 3, 12)) +>const : Symbol(const) + +export const c = ((-1e500)) as const; +>c : Symbol(c, Decl(declarationEmitNegativeNumericConstLiterals.ts, 4, 12)) +>const : Symbol(const) + +export const d = { value: -1e500 } as const; +>d : Symbol(d, Decl(declarationEmitNegativeNumericConstLiterals.ts, 5, 12)) +>value : Symbol(value, Decl(declarationEmitNegativeNumericConstLiterals.ts, 5, 18)) +>const : Symbol(const) + +export const e = [-1e500] as const; +>e : Symbol(e, Decl(declarationEmitNegativeNumericConstLiterals.ts, 6, 12)) +>const : Symbol(const) + +export const f = id(-1e500); +>f : Symbol(f, Decl(declarationEmitNegativeNumericConstLiterals.ts, 7, 12)) +>id : Symbol(id, Decl(declarationEmitNegativeNumericConstLiterals.ts, 0, 0)) + +export const g = -1e500; +>g : Symbol(g, Decl(declarationEmitNegativeNumericConstLiterals.ts, 8, 12)) + +export const h = 1e500; +>h : Symbol(h, Decl(declarationEmitNegativeNumericConstLiterals.ts, 9, 12)) + +export const i = { [-1e500]: 1 } as const; +>i : Symbol(i, Decl(declarationEmitNegativeNumericConstLiterals.ts, 10, 12)) +>[-1e500] : Symbol([-1e500], Decl(declarationEmitNegativeNumericConstLiterals.ts, 10, 18)) +>const : Symbol(const) + diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types new file mode 100644 index 0000000000000..1cd85a80d6467 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts] //// + +=== declarationEmitNegativeNumericConstLiterals.ts === +declare function id(value: T): T; +>id : (value: T) => T +>value : T + +export const a = -1e500 as const; +>a : -Infinity +>-1e500 as const : -Infinity +>-1e500 : -Infinity +>1e500 : Infinity + +export const b = -123456789012345678901234567890 as const; +>b : -1.2345678901234568e+29 +>-123456789012345678901234567890 as const : -1.2345678901234568e+29 +>-123456789012345678901234567890 : -1.2345678901234568e+29 +>123456789012345678901234567890 : 1.2345678901234568e+29 + +export const c = ((-1e500)) as const; +>c : -Infinity +>((-1e500)) as const : -Infinity +>((-1e500)) : -Infinity +>(-1e500) : -Infinity +>-1e500 : -Infinity +>1e500 : Infinity + +export const d = { value: -1e500 } as const; +>d : { readonly value: -Infinity; } +>{ value: -1e500 } as const : { readonly value: -Infinity; } +>{ value: -1e500 } : { readonly value: -Infinity; } +>value : -Infinity +>-1e500 : -Infinity +>1e500 : Infinity + +export const e = [-1e500] as const; +>e : readonly [-Infinity] +>[-1e500] as const : readonly [-Infinity] +>[-1e500] : readonly [-Infinity] +>-1e500 : -Infinity +>1e500 : Infinity + +export const f = id(-1e500); +>f : -Infinity +>id(-1e500) : -Infinity +>id : (value: T) => T +>-1e500 : -Infinity +>1e500 : Infinity + +export const g = -1e500; +>g : -Infinity +>-1e500 : -Infinity +>1e500 : Infinity + +export const h = 1e500; +>h : Infinity +>1e500 : Infinity + +export const i = { [-1e500]: 1 } as const; +>i : { readonly [-Infinity]: 1; } +>{ [-1e500]: 1 } as const : { readonly [-Infinity]: 1; } +>{ [-1e500]: 1 } : { readonly [-Infinity]: 1; } +>[-1e500] : 1 +>-1e500 : -Infinity +>1e500 : Infinity +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js index 6c2bf80435ef2..0c0200ecbdcc7 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js @@ -16,6 +16,11 @@ namespace X { } export const m = X.f(); + +const Infinity = 0; +export enum Bar { + A = 1e999, +} //// [fakeInfinity2.js] @@ -32,6 +37,11 @@ var X; X.f = f; })(X || (X = {})); export const m = X.f(); +const Infinity = 0; +export var Bar; +(function (Bar) { + Bar[Bar["A"] = Infinity] = "A"; +})(Bar || (Bar = {})); //// [fakeInfinity2.d.ts] @@ -40,6 +50,9 @@ export declare enum Foo { B = -Infinity } export declare const m: Infinity; +export declare enum Bar { + A = Infinity +} //// [DtsFileErrors] @@ -56,4 +69,7 @@ fakeInfinity2.d.ts(5,25): error TS2749: 'Infinity' refers to a value, but is bei export declare const m: Infinity; ~~~~~~~~ !!! error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'? + export declare enum Bar { + A = Infinity + } \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.symbols b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.symbols index 3071165542447..2ce84c05419fe 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.symbols +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.symbols @@ -35,3 +35,13 @@ export const m = X.f(); >X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) >f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) +const Infinity = 0; +>Infinity : Symbol(Infinity, Decl(fakeInfinity2.ts, 16, 5)) + +export enum Bar { +>Bar : Symbol(Bar, Decl(fakeInfinity2.ts, 16, 19)) + + A = 1e999, +>A : Symbol(Bar.A, Decl(fakeInfinity2.ts, 17, 17)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types index 0303d2c1d1ef6..4e3f0caffcce7 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types @@ -39,3 +39,15 @@ export const m = X.f(); >X : typeof X >f : () => Infinity +const Infinity = 0; +>Infinity : 0 +>0 : 0 + +export enum Bar { +>Bar : Bar + + A = 1e999, +>A : Bar.A +>1e999 : Infinity +} + diff --git a/tsc/testdata/tests/cases/compiler/constEnumInfinityShadow.ts b/tsc/testdata/tests/cases/compiler/constEnumInfinityShadow.ts new file mode 100644 index 0000000000000..3824e8d15d0b6 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/constEnumInfinityShadow.ts @@ -0,0 +1,10 @@ +// @declaration: true +// @target: esnext + +const Infinity = 0; + +const enum E { + value = 1e999, +} + +export const value = E.value; diff --git a/tsc/testdata/tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts b/tsc/testdata/tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts new file mode 100644 index 0000000000000..2c9fcedeb05f9 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/declarationEmitNegativeNumericConstLiterals.ts @@ -0,0 +1,13 @@ +// @declaration: true + +declare function id(value: T): T; + +export const a = -1e500 as const; +export const b = -123456789012345678901234567890 as const; +export const c = ((-1e500)) as const; +export const d = { value: -1e500 } as const; +export const e = [-1e500] as const; +export const f = id(-1e500); +export const g = -1e500; +export const h = 1e500; +export const i = { [-1e500]: 1 } as const; diff --git a/tsc/testdata/tests/cases/compiler/fakeInfinity2.ts b/tsc/testdata/tests/cases/compiler/fakeInfinity2.ts index 4b0746ac685fb..1942891083900 100644 --- a/tsc/testdata/tests/cases/compiler/fakeInfinity2.ts +++ b/tsc/testdata/tests/cases/compiler/fakeInfinity2.ts @@ -17,3 +17,8 @@ namespace X { } export const m = X.f(); + +const Infinity = 0; +export enum Bar { + A = 1e999, +} From 43d984b8fbffaa1861a7df426a5bd19b165e723a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:39:34 -0700 Subject: [PATCH 2/2] Emit valid syntax for infinite numeric literals Preserve original numeric text when reusable and use 1e999 as a valid infinity spelling for synthesized types, declarations, enum output, completions, and hover. --- tsc/internal/checker/emitresolver.go | 7 +- tsc/internal/checker/nodebuilder_hover.go | 6 ++ tsc/internal/checker/nodebuilderimpl.go | 14 ++-- tsc/internal/checker/nodecopy.go | 21 ++++++ tsc/internal/checker/pseudotypenodebuilder.go | 32 +++++++++- tsc/internal/jsnum/string.go | 2 + tsc/internal/ls/completions.go | 8 ++- .../transformers/declarations/transform.go | 4 +- .../transformers/inliners/constenum.go | 4 +- .../transformers/tstransforms/utilities.go | 4 +- .../compiler/constEnumInfinityShadow.js | 4 +- .../compiler/constEnumInfinityShadow.types | 2 +- .../compiler/declarationEmitEnumNaN.js | 4 +- ...arationEmitNegativeNumericConstLiterals.js | 61 +++--------------- ...tionEmitNegativeNumericConstLiterals.types | 64 +++++++++---------- .../compiler/deferredConditionalTypes2.types | 16 ++--- .../compiler/fakeInfinity1.errors.txt | 4 +- .../reference/compiler/fakeInfinity1.types | 42 ++++++------ .../reference/compiler/fakeInfinity2.js | 34 ++-------- .../reference/compiler/fakeInfinity2.types | 22 +++---- .../reference/compiler/fakeInfinity3.js | 31 ++------- .../reference/compiler/fakeInfinity3.types | 20 +++--- .../binaryIntegerLiteral(target=es2015).types | 2 +- .../conformance/binaryIntegerLiteralES6.types | 2 +- .../conformance/enumConstantMembers.js | 10 +-- .../octalIntegerLiteral(target=es2015).types | 2 +- .../conformance/octalIntegerLiteralES6.types | 2 +- 27 files changed, 206 insertions(+), 218 deletions(-) diff --git a/tsc/internal/checker/emitresolver.go b/tsc/internal/checker/emitresolver.go index 1a4f86696fd2a..8cdddca615f5d 100644 --- a/tsc/internal/checker/emitresolver.go +++ b/tsc/internal/checker/emitresolver.go @@ -1019,9 +1019,12 @@ func (r *EmitResolver) CreateLiteralConstValue(emitContext *printer.EmitContext, case jsnum.Number: if value.IsInf() { if value > 0 { - return emitContext.Factory.NewIdentifier("Infinity") + return emitContext.Factory.NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone) } - return emitContext.Factory.NewPrefixUnaryExpression(ast.KindMinusToken, emitContext.Factory.NewIdentifier("Infinity")) + return emitContext.Factory.NewPrefixUnaryExpression( + ast.KindMinusToken, + emitContext.Factory.NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone), + ) } if value.IsNaN() { return emitContext.Factory.NewIdentifier("NaN") diff --git a/tsc/internal/checker/nodebuilder_hover.go b/tsc/internal/checker/nodebuilder_hover.go index fd5cd55f2b0a7..4c8f50c2e9e83 100644 --- a/tsc/internal/checker/nodebuilder_hover.go +++ b/tsc/internal/checker/nodebuilder_hover.go @@ -101,6 +101,12 @@ func (b *NodeBuilderImpl) enumMemberInitializer(p *ast.Symbol) *ast.Node { case string: return b.f.NewStringLiteral(v, 0) case jsnum.Number: + if v.IsInf() { + if v < 0 { + return b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(jsnum.InfinityLiteralText, 0)) + } + return b.f.NewNumericLiteral(jsnum.InfinityLiteralText, 0) + } return b.f.NewNumericLiteral(v.String(), 0) } return nil diff --git a/tsc/internal/checker/nodebuilderimpl.go b/tsc/internal/checker/nodebuilderimpl.go index 53007b500e8c6..40255a18bf66b 100644 --- a/tsc/internal/checker/nodebuilderimpl.go +++ b/tsc/internal/checker/nodebuilderimpl.go @@ -3311,11 +3311,17 @@ func (b *NodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { } if t.flags&TypeFlagsNumberLiteral != 0 { value := t.AsLiteralType().value.(jsnum.Number) - b.ctx.approximateLength += len(value.String()) - if value < 0 { - return b.f.NewLiteralTypeNode(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(value.String()[1:], ast.TokenFlagsNone))) + negative := value < 0 + text := value.Abs().String() + if value.IsInf() { + text = jsnum.InfinityLiteralText + } + b.ctx.approximateLength += len(text) + if negative { + b.ctx.approximateLength++ + return b.f.NewLiteralTypeNode(b.f.NewPrefixUnaryExpression(ast.KindMinusToken, b.f.NewNumericLiteral(text, ast.TokenFlagsNone))) } else { - return b.f.NewLiteralTypeNode(b.f.NewNumericLiteral(value.String(), ast.TokenFlagsNone)) + return b.f.NewLiteralTypeNode(b.f.NewNumericLiteral(text, ast.TokenFlagsNone)) } } if t.flags&TypeFlagsBigIntLiteral != 0 { diff --git a/tsc/internal/checker/nodecopy.go b/tsc/internal/checker/nodecopy.go index 4f567ed7bd50e..d8932ce1f0b26 100644 --- a/tsc/internal/checker/nodecopy.go +++ b/tsc/internal/checker/nodecopy.go @@ -5,8 +5,10 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/core" + "github.com/microsoft/TypeScript/tsc/internal/jsnum" "github.com/microsoft/TypeScript/tsc/internal/nodebuilder" "github.com/microsoft/TypeScript/tsc/internal/printer" + "github.com/microsoft/TypeScript/tsc/internal/scanner" ) func (b *NodeBuilderImpl) reuseNode(node *ast.Node) *ast.Node { @@ -26,6 +28,14 @@ func (b *NodeBuilderImpl) reuseName(node *ast.Node, isMethod bool) *ast.Node { if res == nil { return res } + if ast.IsComputedPropertyName(node) && ast.IsComputedPropertyName(res) { + sourceLiteral := numericLiteralOperand(node.AsComputedPropertyName().Expression) + reusedLiteral := numericLiteralOperand(res.AsComputedPropertyName().Expression) + if sourceLiteral != nil && reusedLiteral != nil && jsnum.FromString(sourceLiteral.Text()).IsInf() { + sourceFile := ast.GetSourceFileOfNode(sourceLiteral) + reusedLiteral.LiteralLikeData().Text = scanner.GetSourceTextOfNodeFromSourceFile(sourceFile, sourceLiteral, false) + } + } text, ok := ast.TryGetTextOfPropertyName(res) if !ok { @@ -53,6 +63,17 @@ func (b *NodeBuilderImpl) reuseName(node *ast.Node, isMethod bool) *ast.Node { return b.setTextRange(renamed, res) } +func numericLiteralOperand(node *ast.Node) *ast.Node { + node = ast.SkipParentheses(node) + if ast.IsPrefixUnaryExpression(node) { + node = ast.SkipParentheses(node.AsPrefixUnaryExpression().Operand) + } + if ast.IsNumericLiteral(node) { + return node + } + return nil +} + func (b *NodeBuilderImpl) reuseTypeNode(node *ast.Node) *ast.Node { if node == nil { return node diff --git a/tsc/internal/checker/pseudotypenodebuilder.go b/tsc/internal/checker/pseudotypenodebuilder.go index 9daf4b686fc43..3e7e5dbb8587e 100644 --- a/tsc/internal/checker/pseudotypenodebuilder.go +++ b/tsc/internal/checker/pseudotypenodebuilder.go @@ -3,9 +3,11 @@ package checker import ( "github.com/microsoft/TypeScript/tsc/internal/ast" "github.com/microsoft/TypeScript/tsc/internal/debug" + "github.com/microsoft/TypeScript/tsc/internal/jsnum" "github.com/microsoft/TypeScript/tsc/internal/nodebuilder" "github.com/microsoft/TypeScript/tsc/internal/printer" "github.com/microsoft/TypeScript/tsc/internal/pseudochecker" + "github.com/microsoft/TypeScript/tsc/internal/scanner" ) // pseudoTypeToNodeWithCheckerFallback is like pseudoTypeToNode but when the top-level pseudo type @@ -317,13 +319,41 @@ func (b *NodeBuilderImpl) pseudoTypeToNode(t *pseudochecker.PseudoType) *ast.Nod return result case pseudochecker.PseudoTypeKindStringLiteral, pseudochecker.PseudoTypeKindNumericLiteral, pseudochecker.PseudoTypeKindBigIntLiteral: source := t.AsPseudoTypeLiteral().Node - return b.f.NewLiteralTypeNode(b.reuseNode(source)) + reused := b.reuseNode(source) + if t.Kind == pseudochecker.PseudoTypeKindNumericLiteral { + sourceLiteral := source + reusedLiteral := reused + if ast.IsPrefixUnaryExpression(source) { + sourceLiteral = source.AsPrefixUnaryExpression().Operand + reusedLiteral = reused.AsPrefixUnaryExpression().Operand + } + if isDirectlyConstAssertedNumericLiteral(source) { + // Numeric literal text stores the rounded value, so recover the source spelling for reused const assertions. + sourceFile := ast.GetSourceFileOfNode(sourceLiteral) + reusedLiteral.LiteralLikeData().Text = scanner.GetSourceTextOfNodeFromSourceFile(sourceFile, sourceLiteral, false) + } else if jsnum.FromString(sourceLiteral.Text()).IsInf() { + reusedLiteral.LiteralLikeData().Text = jsnum.InfinityLiteralText + } + } + return b.f.NewLiteralTypeNode(reused) default: debug.AssertNever(t.Kind, "Unhandled pseudotype kind in pseudotype node construction") return nil } } +func isDirectlyConstAssertedNumericLiteral(node *ast.Node) bool { + for parent := node.Parent; parent != nil; parent = parent.Parent { + if ast.IsConstAssertion(parent) { + return true + } + if !ast.IsPrefixUnaryExpression(parent) && !ast.IsParenthesizedExpression(parent) { + return false + } + } + return false +} + func (b *NodeBuilderImpl) pseudoParametersToNodeList(params []*pseudochecker.PseudoParameter) *ast.NodeList { res := make([]*ast.Node, 0, len(params)) for _, p := range params { diff --git a/tsc/internal/jsnum/string.go b/tsc/internal/jsnum/string.go index 639dd7f59380a..08d0cd9f92feb 100644 --- a/tsc/internal/jsnum/string.go +++ b/tsc/internal/jsnum/string.go @@ -13,6 +13,8 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/stringutil" ) +const InfinityLiteralText = "1e999" + // https://tc39.es/ecma262/2024/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring func (n Number) String() string { switch { diff --git a/tsc/internal/ls/completions.go b/tsc/internal/ls/completions.go index 2aef35353d1b1..e1371dee8a7ba 100644 --- a/tsc/internal/ls/completions.go +++ b/tsc/internal/ls/completions.go @@ -6636,10 +6636,14 @@ func (l *LanguageService) getExhaustiveCaseSnippets( elements = append(elements, bigInt) case jsnum.Number: var number *ast.Node + text := v.Abs().String() + if v.IsInf() { + text = jsnum.InfinityLiteralText + } if v < 0 { - number = factory.NewPrefixUnaryExpression(ast.KindMinusToken, factory.NewNumericLiteral(v.Abs().String(), ast.TokenFlagsNone)) + number = factory.NewPrefixUnaryExpression(ast.KindMinusToken, factory.NewNumericLiteral(text, ast.TokenFlagsNone)) } else { - number = factory.NewNumericLiteral(v.String(), ast.TokenFlagsNone) + number = factory.NewNumericLiteral(text, ast.TokenFlagsNone) } elements = append(elements, number) case string: diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 08e26b96a82fd..fb694606e512c 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -2286,9 +2286,9 @@ func (tx *DeclarationTransformer) transformEnumDeclaration(input *ast.EnumDeclar case jsnum.Number: if value.IsInf() { if value > 0 { - newInitializer = tx.Factory().NewIdentifier("Infinity") + newInitializer = tx.Factory().NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone) } else { - newInitializer = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewIdentifier("Infinity")) + newInitializer = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone)) } } else if value.IsNaN() { newInitializer = tx.Factory().NewIdentifier("NaN") diff --git a/tsc/internal/transformers/inliners/constenum.go b/tsc/internal/transformers/inliners/constenum.go index f3be363c8393a..132ed2d99472e 100644 --- a/tsc/internal/transformers/inliners/constenum.go +++ b/tsc/internal/transformers/inliners/constenum.go @@ -44,9 +44,9 @@ func (tx *ConstEnumInliningTransformer) visit(node *ast.Node) *ast.Node { case jsnum.Number: if v.IsInf() { if v.Abs() == v { - replacement = tx.Factory().NewIdentifier("Infinity") + replacement = tx.Factory().NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone) } else { - replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewIdentifier("Infinity")) + replacement = tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone)) } } else if v.IsNaN() { replacement = tx.Factory().NewIdentifier("NaN") diff --git a/tsc/internal/transformers/tstransforms/utilities.go b/tsc/internal/transformers/tstransforms/utilities.go index 2c0f0eb5478c6..b6f8df2427205 100644 --- a/tsc/internal/transformers/tstransforms/utilities.go +++ b/tsc/internal/transformers/tstransforms/utilities.go @@ -13,9 +13,9 @@ func constantExpression(value any, factory *printer.NodeFactory) *ast.Expression case jsnum.Number: if value.IsInf() { if value > 0 { - return factory.NewIdentifier("Infinity") + return factory.NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone) } - return factory.NewPrefixUnaryExpression(ast.KindMinusToken, factory.NewIdentifier("Infinity")) + return factory.NewPrefixUnaryExpression(ast.KindMinusToken, factory.NewNumericLiteral(jsnum.InfinityLiteralText, ast.TokenFlagsNone)) } if value.IsNaN() { return factory.NewIdentifier("NaN") diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js index a4946398f6887..a106d84355268 100644 --- a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.js @@ -12,12 +12,12 @@ export const value = E.value; //// [constEnumInfinityShadow.js] const Infinity = 0; -export const value = Infinity /* E.value */; +export const value = 1e999 /* E.value */; //// [constEnumInfinityShadow.d.ts] declare const enum E { - value = Infinity + value = 1e999 } export declare const value = E.value; export {}; diff --git a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types index acb14e5a21a12..8436bd94ef87e 100644 --- a/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types +++ b/tsc/testdata/baselines/reference/compiler/constEnumInfinityShadow.types @@ -10,7 +10,7 @@ const enum E { value = 1e999, >value : E.value ->1e999 : Infinity +>1e999 : 1e999 } export const value = E.value; diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitEnumNaN.js b/tsc/testdata/baselines/reference/compiler/declarationEmitEnumNaN.js index 4286863207494..47ced2e358b73 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitEnumNaN.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitEnumNaN.js @@ -15,6 +15,6 @@ export declare enum E { export declare enum E { A = NaN, B = NaN, - C = Infinity, - D = -Infinity + C = 1e999, + D = -1e999 } diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js index 48f0eb43553b3..71cd6ac467a46 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.js @@ -27,59 +27,16 @@ export const i = { [-1e500]: 1 }; //// [declarationEmitNegativeNumericConstLiterals.d.ts] -export declare const a: -Infinity; -export declare const b: -1.2345678901234568e+29; -export declare const c: -Infinity; +export declare const a: -1e500; +export declare const b: -123456789012345678901234567890; +export declare const c: -1e500; export declare const d: { - readonly value: -Infinity; + readonly value: -1e999; }; -export declare const e: readonly [-Infinity]; -export declare const f: -Infinity; -export declare const g = -Infinity; -export declare const h = Infinity; +export declare const e: readonly [-1e999]; +export declare const f: -1e999; +export declare const g = -1e999; +export declare const h = 1e999; export declare const i: { - readonly [-Infinity]: 1; + readonly [-1e500]: 1; }; - - -//// [DtsFileErrors] - - -declarationEmitNegativeNumericConstLiterals.d.ts(1,25): error TS1110: Type expected. -declarationEmitNegativeNumericConstLiterals.d.ts(3,25): error TS1110: Type expected. -declarationEmitNegativeNumericConstLiterals.d.ts(5,21): error TS1110: Type expected. -declarationEmitNegativeNumericConstLiterals.d.ts(6,1): error TS1128: Declaration or statement expected. -declarationEmitNegativeNumericConstLiterals.d.ts(7,35): error TS1110: Type expected. -declarationEmitNegativeNumericConstLiterals.d.ts(7,44): error TS1005: ';' expected. -declarationEmitNegativeNumericConstLiterals.d.ts(8,25): error TS1110: Type expected. - - -==== declarationEmitNegativeNumericConstLiterals.d.ts (7 errors) ==== - export declare const a: -Infinity; - ~ -!!! error TS1110: Type expected. - export declare const b: -1.2345678901234568e+29; - export declare const c: -Infinity; - ~ -!!! error TS1110: Type expected. - export declare const d: { - readonly value: -Infinity; - ~ -!!! error TS1110: Type expected. - }; - ~ -!!! error TS1128: Declaration or statement expected. - export declare const e: readonly [-Infinity]; - ~ -!!! error TS1110: Type expected. - ~ -!!! error TS1005: ';' expected. - export declare const f: -Infinity; - ~ -!!! error TS1110: Type expected. - export declare const g = -Infinity; - export declare const h = Infinity; - export declare const i: { - readonly [-Infinity]: 1; - }; - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types index 1cd85a80d6467..911cd2792a341 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitNegativeNumericConstLiterals.types @@ -6,10 +6,10 @@ declare function id(value: T): T; >value : T export const a = -1e500 as const; ->a : -Infinity ->-1e500 as const : -Infinity ->-1e500 : -Infinity ->1e500 : Infinity +>a : -1e999 +>-1e500 as const : -1e999 +>-1e500 : -1e999 +>1e500 : 1e999 export const b = -123456789012345678901234567890 as const; >b : -1.2345678901234568e+29 @@ -18,50 +18,50 @@ export const b = -123456789012345678901234567890 as const; >123456789012345678901234567890 : 1.2345678901234568e+29 export const c = ((-1e500)) as const; ->c : -Infinity ->((-1e500)) as const : -Infinity ->((-1e500)) : -Infinity ->(-1e500) : -Infinity ->-1e500 : -Infinity ->1e500 : Infinity +>c : -1e999 +>((-1e500)) as const : -1e999 +>((-1e500)) : -1e999 +>(-1e500) : -1e999 +>-1e500 : -1e999 +>1e500 : 1e999 export const d = { value: -1e500 } as const; ->d : { readonly value: -Infinity; } ->{ value: -1e500 } as const : { readonly value: -Infinity; } ->{ value: -1e500 } : { readonly value: -Infinity; } ->value : -Infinity ->-1e500 : -Infinity ->1e500 : Infinity +>d : { readonly value: -1e999; } +>{ value: -1e500 } as const : { readonly value: -1e999; } +>{ value: -1e500 } : { readonly value: -1e999; } +>value : -1e999 +>-1e500 : -1e999 +>1e500 : 1e999 export const e = [-1e500] as const; ->e : readonly [-Infinity] ->[-1e500] as const : readonly [-Infinity] ->[-1e500] : readonly [-Infinity] ->-1e500 : -Infinity ->1e500 : Infinity +>e : readonly [-1e999] +>[-1e500] as const : readonly [-1e999] +>[-1e500] : readonly [-1e999] +>-1e500 : -1e999 +>1e500 : 1e999 export const f = id(-1e500); ->f : -Infinity ->id(-1e500) : -Infinity +>f : -1e999 +>id(-1e500) : -1e999 >id : (value: T) => T ->-1e500 : -Infinity ->1e500 : Infinity +>-1e500 : -1e999 +>1e500 : 1e999 export const g = -1e500; ->g : -Infinity ->-1e500 : -Infinity ->1e500 : Infinity +>g : -1e999 +>-1e500 : -1e999 +>1e500 : 1e999 export const h = 1e500; ->h : Infinity ->1e500 : Infinity +>h : 1e999 +>1e500 : 1e999 export const i = { [-1e500]: 1 } as const; >i : { readonly [-Infinity]: 1; } >{ [-1e500]: 1 } as const : { readonly [-Infinity]: 1; } >{ [-1e500]: 1 } : { readonly [-Infinity]: 1; } >[-1e500] : 1 ->-1e500 : -Infinity ->1e500 : Infinity +>-1e500 : -1e999 +>1e500 : 1e999 >1 : 1 diff --git a/tsc/testdata/baselines/reference/compiler/deferredConditionalTypes2.types b/tsc/testdata/baselines/reference/compiler/deferredConditionalTypes2.types index a14eb9574aa16..8e96c04c2f77f 100644 --- a/tsc/testdata/baselines/reference/compiler/deferredConditionalTypes2.types +++ b/tsc/testdata/baselines/reference/compiler/deferredConditionalTypes2.types @@ -4,12 +4,12 @@ // https://github.com/microsoft/TypeScript/issues/56270 type PositiveInfinity = 1e999; ->PositiveInfinity : Infinity +>PositiveInfinity : 1e999 type NegativeInfinity = -1e999; ->NegativeInfinity : -Infinity ->-1e999 : -Infinity ->1e999 : Infinity +>NegativeInfinity : -1e999 +>-1e999 : -1e999 +>1e999 : 1e999 export type IsEqual = (() => G extends A ? 1 : 2) extends < >IsEqual : IsEqual @@ -23,7 +23,7 @@ export type IsEqual = (() => G extends A ? 1 : 2) extends < >false : false export type Add = [ ->Add : [true, false] extends [IsEqual, IsEqual] ? Infinity : "failed" +>Add : [true, false] extends [IsEqual, IsEqual] ? 1e999 : "failed" IsEqual, IsEqual, @@ -39,7 +39,7 @@ export type Add = [ : never; export type AddWithoutParentheses = [ ->AddWithoutParentheses : [true, false] extends [IsEqual, IsEqual] ? Infinity : "failed" +>AddWithoutParentheses : [true, false] extends [IsEqual, IsEqual] ? 1e999 : "failed" IsEqual, IsEqual, @@ -55,8 +55,8 @@ export type AddWithoutParentheses = [ : never; type AddTest0 = Add; ->AddTest0 : Infinity +>AddTest0 : 1e999 type AddTest1 = AddWithoutParentheses; ->AddTest1 : Infinity +>AddTest1 : 1e999 diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity1.errors.txt b/tsc/testdata/baselines/reference/compiler/fakeInfinity1.errors.txt index 52fd2751609ed..d93bc61129ec0 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity1.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity1.errors.txt @@ -1,4 +1,4 @@ -fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'. +fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type '1e999'. ==== fakeInfinity1.ts (1 errors) ==== @@ -20,7 +20,7 @@ fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'I a = Infinity; ~ -!!! error TS2322: Type 'number' is not assignable to type 'Infinity'. +!!! error TS2322: Type 'number' is not assignable to type '1e999'. a = 1e999; a = 1e9999; diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity1.types b/tsc/testdata/baselines/reference/compiler/fakeInfinity1.types index 0d5f3d1aa4f37..1de61f7f34f94 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity1.types +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity1.types @@ -3,12 +3,12 @@ === fakeInfinity1.ts === // These are not actually the real infinity. export type PositiveInfinity = 1e999; ->PositiveInfinity : Infinity +>PositiveInfinity : 1e999 export type NegativeInfinity = -1e999; ->NegativeInfinity : -Infinity ->-1e999 : -Infinity ->1e999 : Infinity +>NegativeInfinity : -1e999 +>-1e999 : -1e999 +>1e999 : 1e999 export type TypeOfInfinity = typeof Infinity; >TypeOfInfinity : number @@ -19,41 +19,41 @@ export type TypeOfNaN = typeof NaN; >NaN : number type A = 1e999; ->A : Infinity +>A : 1e999 type B = 1e9999; ->B : Infinity +>B : 1e999 declare let a: A; ->a : Infinity +>a : 1e999 declare let b: B; ->b : Infinity +>b : 1e999 a = b; ->a = b : Infinity ->a : Infinity ->b : Infinity +>a = b : 1e999 +>a : 1e999 +>b : 1e999 b = a; ->b = a : Infinity ->b : Infinity ->a : Infinity +>b = a : 1e999 +>b : 1e999 +>a : 1e999 a = Infinity; >a = Infinity : number ->a : Infinity +>a : 1e999 >Infinity : number a = 1e999; ->a = 1e999 : Infinity ->a : Infinity ->1e999 : Infinity +>a = 1e999 : 1e999 +>a : 1e999 +>1e999 : 1e999 a = 1e9999; ->a = 1e9999 : Infinity ->a : Infinity ->1e9999 : Infinity +>a = 1e9999 : 1e999 +>a : 1e999 +>1e9999 : 1e999 export type Oops = 123456789123456789123456789123456789123456789123456789; >Oops : 1.2345678912345678e+53 diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js index 0c0200ecbdcc7..034b295749cfd 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.js @@ -26,8 +26,8 @@ export enum Bar { //// [fakeInfinity2.js] export var Foo; (function (Foo) { - Foo[Foo["A"] = Infinity] = "A"; - Foo[Foo["B"] = -Infinity] = "B"; + Foo[Foo["A"] = 1e999] = "A"; + Foo[Foo["B"] = -1e999] = "B"; })(Foo || (Foo = {})); var X; (function (X) { @@ -40,36 +40,16 @@ export const m = X.f(); const Infinity = 0; export var Bar; (function (Bar) { - Bar[Bar["A"] = Infinity] = "A"; + Bar[Bar["A"] = 1e999] = "A"; })(Bar || (Bar = {})); //// [fakeInfinity2.d.ts] export declare enum Foo { - A = Infinity, - B = -Infinity + A = 1e999, + B = -1e999 } -export declare const m: Infinity; +export declare const m: 1e999; export declare enum Bar { - A = Infinity + A = 1e999 } - - -//// [DtsFileErrors] - - -fakeInfinity2.d.ts(5,25): error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'? - - -==== fakeInfinity2.d.ts (1 errors) ==== - export declare enum Foo { - A = Infinity, - B = -Infinity - } - export declare const m: Infinity; - ~~~~~~~~ -!!! error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'? - export declare enum Bar { - A = Infinity - } - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types index 4e3f0caffcce7..c157c9db07a83 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity2.types @@ -6,25 +6,25 @@ export enum Foo { A = 1e999, >A : Foo.A ->1e999 : Infinity +>1e999 : 1e999 B = -1e999, >B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity +>-1e999 : -1e999 +>1e999 : 1e999 } namespace X { >X : typeof X type A = 1e999; ->A : Infinity +>A : 1e999 type B = 2e999; ->B : Infinity +>B : 1e999 export function f(): A { ->f : () => Infinity +>f : () => 1e999 throw new Error() >new Error() : Error @@ -33,11 +33,11 @@ namespace X { } export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity +>m : 1e999 +>X.f() : 1e999 +>X.f : () => 1e999 >X : typeof X ->f : () => Infinity +>f : () => 1e999 const Infinity = 0; >Infinity : 0 @@ -48,6 +48,6 @@ export enum Bar { A = 1e999, >A : Bar.A ->1e999 : Infinity +>1e999 : 1e999 } diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity3.js b/tsc/testdata/baselines/reference/compiler/fakeInfinity3.js index dbde9c2ce72b8..691bca56c0288 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity3.js +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity3.js @@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Infinity = exports.m = exports.Foo = void 0; var Foo; (function (Foo) { - Foo[Foo["A"] = Infinity] = "A"; - Foo[Foo["B"] = -Infinity] = "B"; + Foo[Foo["A"] = 1e999] = "A"; + Foo[Foo["B"] = -1e999] = "B"; })(Foo || (exports.Foo = Foo = {})); var X; (function (X) { @@ -42,29 +42,8 @@ exports.Infinity = "oops"; //// [fakeInfinity3.d.ts] export declare enum Foo { - A = Infinity, - B = -Infinity + A = 1e999, + B = -1e999 } -export declare const m: Infinity; +export declare const m: 1e999; export declare const Infinity = "oops"; - - -//// [DtsFileErrors] - - -fakeInfinity3.d.ts(3,9): error TS1066: In ambient enum declarations member initializer must be constant expression. -fakeInfinity3.d.ts(5,25): error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'? - - -==== fakeInfinity3.d.ts (2 errors) ==== - export declare enum Foo { - A = Infinity, - B = -Infinity - ~~~~~~~~~ -!!! error TS1066: In ambient enum declarations member initializer must be constant expression. - } - export declare const m: Infinity; - ~~~~~~~~ -!!! error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'? - export declare const Infinity = "oops"; - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/fakeInfinity3.types b/tsc/testdata/baselines/reference/compiler/fakeInfinity3.types index 30eb4d11a9a62..d2b6e7ce9f591 100644 --- a/tsc/testdata/baselines/reference/compiler/fakeInfinity3.types +++ b/tsc/testdata/baselines/reference/compiler/fakeInfinity3.types @@ -6,25 +6,25 @@ export enum Foo { A = 1e999, >A : Foo.A ->1e999 : Infinity +>1e999 : 1e999 B = -1e999, >B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity +>-1e999 : -1e999 +>1e999 : 1e999 } namespace X { >X : typeof X type A = 1e999; ->A : Infinity +>A : 1e999 type B = 2e999; ->B : Infinity +>B : 1e999 export function f(): A { ->f : () => Infinity +>f : () => 1e999 throw new Error() >new Error() : Error @@ -33,11 +33,11 @@ namespace X { } export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity +>m : 1e999 +>X.f() : 1e999 +>X.f : () => 1e999 >X : typeof X ->f : () => Infinity +>f : () => 1e999 export const Infinity = "oops"; >Infinity : "oops" diff --git a/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteral(target=es2015).types b/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteral(target=es2015).types index aa6cdca80f98f..c52cd0c8afe55 100644 --- a/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteral(target=es2015).types +++ b/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteral(target=es2015).types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : 1e999 var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteralES6.types b/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteralES6.types index da62188a6b338..3681adaedd42a 100644 --- a/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteralES6.types +++ b/tsc/testdata/baselines/reference/conformance/binaryIntegerLiteralES6.types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : 1e999 var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tsc/testdata/baselines/reference/conformance/enumConstantMembers.js b/tsc/testdata/baselines/reference/conformance/enumConstantMembers.js index f38cf9b670690..54f0d5a42e962 100644 --- a/tsc/testdata/baselines/reference/conformance/enumConstantMembers.js +++ b/tsc/testdata/baselines/reference/conformance/enumConstantMembers.js @@ -62,11 +62,11 @@ var E3; })(E3 || (E3 = {})); var E5; (function (E5) { - E5[E5["a"] = Infinity] = "a"; - E5[E5["b"] = Infinity] = "b"; - E5[E5["c"] = Infinity] = "c"; + E5[E5["a"] = 1e999] = "a"; + E5[E5["b"] = 1e999] = "b"; + E5[E5["c"] = 1e999] = "c"; E5[E5["d"] = NaN] = "d"; E5[E5["e"] = NaN] = "e"; - E5[E5["f"] = Infinity] = "f"; - E5[E5["g"] = -Infinity] = "g"; + E5[E5["f"] = 1e999] = "f"; + E5[E5["g"] = -1e999] = "g"; })(E5 || (E5 = {})); diff --git a/tsc/testdata/baselines/reference/conformance/octalIntegerLiteral(target=es2015).types b/tsc/testdata/baselines/reference/conformance/octalIntegerLiteral(target=es2015).types index afd9fbd1a8e86..cc4e0151efbba 100644 --- a/tsc/testdata/baselines/reference/conformance/octalIntegerLiteral(target=es2015).types +++ b/tsc/testdata/baselines/reference/conformance/octalIntegerLiteral(target=es2015).types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : 1e999 var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number diff --git a/tsc/testdata/baselines/reference/conformance/octalIntegerLiteralES6.types b/tsc/testdata/baselines/reference/conformance/octalIntegerLiteralES6.types index ba681dfdb6b0a..2be6ae671a021 100644 --- a/tsc/testdata/baselines/reference/conformance/octalIntegerLiteralES6.types +++ b/tsc/testdata/baselines/reference/conformance/octalIntegerLiteralES6.types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : 1e999 var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number