From 3d7c53dfc431c6c51e3c1264c1e8f09def200b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 28 Nov 2023 08:05:07 +0100 Subject: [PATCH 1/6] Revert "Revert "Disallow numeric literals with negative numbers (#55268)" (#56422)" This reverts commit 3333e906ddce997003f8f1a001a56438f55d5c35. --- src/compiler/checker.ts | 16 +++-- src/compiler/factory/nodeFactory.ts | 5 +- src/compiler/transformers/declarations.ts | 9 ++- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/ts.ts | 4 +- .../reference/binaryIntegerLiteral.types | 2 +- .../reference/binaryIntegerLiteralES6.types | 2 +- .../reference/fakeInfinity1.errors.txt | 29 -------- tests/baselines/reference/fakeInfinity1.js | 46 ------------ .../baselines/reference/fakeInfinity1.symbols | 56 --------------- tests/baselines/reference/fakeInfinity1.types | 64 ----------------- tests/baselines/reference/fakeInfinity2.js | 62 ---------------- .../baselines/reference/fakeInfinity2.symbols | 37 ---------- tests/baselines/reference/fakeInfinity2.types | 41 ----------- tests/baselines/reference/fakeInfinity3.js | 70 ------------------- .../baselines/reference/fakeInfinity3.symbols | 40 ----------- tests/baselines/reference/fakeInfinity3.types | 45 ------------ .../reference/octalIntegerLiteral.types | 2 +- .../reference/octalIntegerLiteralES6.types | 2 +- tests/cases/compiler/fakeInfinity1.ts | 25 ------- tests/cases/compiler/fakeInfinity2.ts | 18 ----- tests/cases/compiler/fakeInfinity3.ts | 20 ------ 22 files changed, 31 insertions(+), 566 deletions(-) delete mode 100644 tests/baselines/reference/fakeInfinity1.errors.txt delete mode 100644 tests/baselines/reference/fakeInfinity1.js delete mode 100644 tests/baselines/reference/fakeInfinity1.symbols delete mode 100644 tests/baselines/reference/fakeInfinity1.types delete mode 100644 tests/baselines/reference/fakeInfinity2.js delete mode 100644 tests/baselines/reference/fakeInfinity2.symbols delete mode 100644 tests/baselines/reference/fakeInfinity2.types delete mode 100644 tests/baselines/reference/fakeInfinity3.js delete mode 100644 tests/baselines/reference/fakeInfinity3.symbols delete mode 100644 tests/baselines/reference/fakeInfinity3.types delete mode 100644 tests/cases/compiler/fakeInfinity1.ts delete mode 100644 tests/cases/compiler/fakeInfinity2.ts delete mode 100644 tests/cases/compiler/fakeInfinity3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 459553a27debf..8c22cbfc6a6a6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8331,7 +8331,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return factory.createStringLiteral(name, !!singleQuote); } if (isNumericLiteralName(name) && startsWith(name, "-")) { - return factory.createComputedPropertyName(factory.createNumericLiteral(+name)); + return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(+name)))); } return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod); } @@ -39021,9 +39021,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return hasSkipDirectInferenceFlag(node) ? blockedStringType : getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text)); - case SyntaxKind.NumericLiteral: + case SyntaxKind.NumericLiteral: { checkGrammarNumericLiteral(node as NumericLiteral); - return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text)); + const value = +(node as NumericLiteral).text; + if (!isFinite(value)) { + return numberType; + } + return getFreshTypeOfLiteralType(getNumberLiteralType(value)); + } case SyntaxKind.BigIntLiteral: checkGrammarBigIntLiteral(node as BigIntLiteral); return getFreshTypeOfLiteralType(getBigIntLiteralType({ @@ -47998,8 +48003,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (enumResult) return enumResult; const literalValue = (type as LiteralType).value; return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : - typeof literalValue === "number" ? factory.createNumericLiteral(literalValue) : - factory.createStringLiteral(literalValue); + typeof literalValue === "string" ? factory.createStringLiteral(literalValue) : + literalValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(literalValue))) : + factory.createNumericLiteral(literalValue); } function createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, tracker: SymbolTracker) { diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 0de2b201803d9..907ab3833b672 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -44,6 +44,7 @@ import { CaseOrDefaultClause, cast, CatchClause, + CharacterCodes, ClassDeclaration, ClassElement, ClassExpression, @@ -1254,8 +1255,10 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode // @api function createNumericLiteral(value: string | number, numericLiteralFlags: TokenFlags = TokenFlags.None): NumericLiteral { + const text = typeof value === "number" ? value + "" : value; + Debug.assert(text.charCodeAt(0) !== CharacterCodes.minus, "Negative numbers should be created in combination with createPrefixUnaryExpression"); const node = createBaseDeclaration(SyntaxKind.NumericLiteral); - node.text = typeof value === "number" ? value + "" : value; + node.text = text; node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & TokenFlags.BinaryOrOctalSpecifier) node.transformFlags |= TransformFlags.ContainsES2015; return node; diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 45a5df4f0b95d..2094911ef14df 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1798,7 +1798,14 @@ export function transformDeclarations(context: TransformationContext) { if (shouldStripInternal(m)) return; // Rewrite enum values to their constants, if available const constValue = resolver.getConstantValue(m); - return preserveJsDoc(factory.updateEnumMember(m, m.name, constValue !== undefined ? typeof constValue === "string" ? factory.createStringLiteral(constValue) : factory.createNumericLiteral(constValue) : undefined), m); + const newInitializer = constValue === undefined + ? undefined + : typeof constValue === "string" + ? factory.createStringLiteral(constValue) + : constValue < 0 + ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(constValue))) + : factory.createNumericLiteral(constValue); + return preserveJsDoc(factory.updateEnumMember(m, m.name, newInitializer), m); })), )); } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 39f9a967e0cb3..775075a6e8f6f 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -2524,7 +2524,7 @@ export function transformGenerators(context: TransformationContext): (x: SourceF labelExpressions = []; } - const expression = factory.createNumericLiteral(-1); + const expression = factory.createNumericLiteral(Number.MAX_SAFE_INTEGER); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index ac5855d72c8de..584cf837e180a 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1901,7 +1901,9 @@ export function transformTypeScript(context: TransformationContext) { function transformEnumMemberDeclarationValue(member: EnumMember): Expression { const value = resolver.getConstantValue(member); if (value !== undefined) { - return typeof value === "string" ? factory.createStringLiteral(value) : factory.createNumericLiteral(value); + return typeof value === "string" ? factory.createStringLiteral(value) : + value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))) : + factory.createNumericLiteral(value); } else { enableSubstitutionForNonQualifiedEnumMembers(); diff --git a/tests/baselines/reference/binaryIntegerLiteral.types b/tests/baselines/reference/binaryIntegerLiteral.types index 2c81595c0c8b4..48b9d9532cc1a 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.types +++ b/tests/baselines/reference/binaryIntegerLiteral.types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.types b/tests/baselines/reference/binaryIntegerLiteralES6.types index 2abc7ca72ca22..8b6d7437affd4 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.types +++ b/tests/baselines/reference/binaryIntegerLiteralES6.types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tests/baselines/reference/fakeInfinity1.errors.txt b/tests/baselines/reference/fakeInfinity1.errors.txt deleted file mode 100644 index 52fd2751609ed..0000000000000 --- a/tests/baselines/reference/fakeInfinity1.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'. - - -==== fakeInfinity1.ts (1 errors) ==== - // These are not actually the real infinity. - export type PositiveInfinity = 1e999; - export type NegativeInfinity = -1e999; - - export type TypeOfInfinity = typeof Infinity; - export type TypeOfNaN = typeof NaN; - - type A = 1e999; - type B = 1e9999; - - declare let a: A; - declare let b: B; - - a = b; - b = a; - - a = Infinity; - ~ -!!! error TS2322: Type 'number' is not assignable to type 'Infinity'. - a = 1e999; - a = 1e9999; - - export type Oops = 123456789123456789123456789123456789123456789123456789; - export const oops = 123456789123456789123456789123456789123456789123456789; - \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity1.js b/tests/baselines/reference/fakeInfinity1.js deleted file mode 100644 index c28497a9fa3a0..0000000000000 --- a/tests/baselines/reference/fakeInfinity1.js +++ /dev/null @@ -1,46 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -//// [fakeInfinity1.ts] -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; -export type NegativeInfinity = -1e999; - -export type TypeOfInfinity = typeof Infinity; -export type TypeOfNaN = typeof NaN; - -type A = 1e999; -type B = 1e9999; - -declare let a: A; -declare let b: B; - -a = b; -b = a; - -a = Infinity; -a = 1e999; -a = 1e9999; - -export type Oops = 123456789123456789123456789123456789123456789123456789; -export const oops = 123456789123456789123456789123456789123456789123456789; - - -//// [fakeInfinity1.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.oops = void 0; -a = b; -b = a; -a = Infinity; -a = 1e999; -a = 1e9999; -exports.oops = 123456789123456789123456789123456789123456789123456789; - - -//// [fakeInfinity1.d.ts] -export type PositiveInfinity = 1e999; -export type NegativeInfinity = -1e999; -export type TypeOfInfinity = typeof Infinity; -export type TypeOfNaN = typeof NaN; -export type Oops = 123456789123456789123456789123456789123456789123456789; -export declare const oops = 1.2345678912345678e+53; diff --git a/tests/baselines/reference/fakeInfinity1.symbols b/tests/baselines/reference/fakeInfinity1.symbols deleted file mode 100644 index 07cb183dae865..0000000000000 --- a/tests/baselines/reference/fakeInfinity1.symbols +++ /dev/null @@ -1,56 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -=== fakeInfinity1.ts === -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; ->PositiveInfinity : Symbol(PositiveInfinity, Decl(fakeInfinity1.ts, 0, 0)) - -export type NegativeInfinity = -1e999; ->NegativeInfinity : Symbol(NegativeInfinity, Decl(fakeInfinity1.ts, 1, 37)) - -export type TypeOfInfinity = typeof Infinity; ->TypeOfInfinity : Symbol(TypeOfInfinity, Decl(fakeInfinity1.ts, 2, 38)) ->Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) - -export type TypeOfNaN = typeof NaN; ->TypeOfNaN : Symbol(TypeOfNaN, Decl(fakeInfinity1.ts, 4, 45)) ->NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) - -type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) - -type B = 1e9999; ->B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) - -declare let a: A; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) - -declare let b: B; ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) ->B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) - -a = b; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) - -b = a; ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -a = Infinity; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) - -a = 1e999; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -a = 1e9999; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -export type Oops = 123456789123456789123456789123456789123456789123456789; ->Oops : Symbol(Oops, Decl(fakeInfinity1.ts, 18, 11)) - -export const oops = 123456789123456789123456789123456789123456789123456789; ->oops : Symbol(oops, Decl(fakeInfinity1.ts, 21, 12)) - diff --git a/tests/baselines/reference/fakeInfinity1.types b/tests/baselines/reference/fakeInfinity1.types deleted file mode 100644 index 0d5f3d1aa4f37..0000000000000 --- a/tests/baselines/reference/fakeInfinity1.types +++ /dev/null @@ -1,64 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -=== fakeInfinity1.ts === -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; ->PositiveInfinity : Infinity - -export type NegativeInfinity = -1e999; ->NegativeInfinity : -Infinity ->-1e999 : -Infinity ->1e999 : Infinity - -export type TypeOfInfinity = typeof Infinity; ->TypeOfInfinity : number ->Infinity : number - -export type TypeOfNaN = typeof NaN; ->TypeOfNaN : number ->NaN : number - -type A = 1e999; ->A : Infinity - -type B = 1e9999; ->B : Infinity - -declare let a: A; ->a : Infinity - -declare let b: B; ->b : Infinity - -a = b; ->a = b : Infinity ->a : Infinity ->b : Infinity - -b = a; ->b = a : Infinity ->b : Infinity ->a : Infinity - -a = Infinity; ->a = Infinity : number ->a : Infinity ->Infinity : number - -a = 1e999; ->a = 1e999 : Infinity ->a : Infinity ->1e999 : Infinity - -a = 1e9999; ->a = 1e9999 : Infinity ->a : Infinity ->1e9999 : Infinity - -export type Oops = 123456789123456789123456789123456789123456789123456789; ->Oops : 1.2345678912345678e+53 - -export const oops = 123456789123456789123456789123456789123456789123456789; ->oops : 1.2345678912345678e+53 ->123456789123456789123456789123456789123456789123456789 : 1.2345678912345678e+53 - diff --git a/tests/baselines/reference/fakeInfinity2.js b/tests/baselines/reference/fakeInfinity2.js deleted file mode 100644 index 779b0f421d988..0000000000000 --- a/tests/baselines/reference/fakeInfinity2.js +++ /dev/null @@ -1,62 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -//// [fakeInfinity2.ts] -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); - - -//// [fakeInfinity2.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.m = exports.Foo = void 0; -var Foo; -(function (Foo) { - Foo[Foo["A"] = Infinity] = "A"; - Foo[Foo["B"] = -Infinity] = "B"; -})(Foo || (exports.Foo = Foo = {})); -var X; -(function (X) { - function f() { - throw new Error(); - } - X.f = f; -})(X || (X = {})); -exports.m = X.f(); - - -//// [fakeInfinity2.d.ts] -export declare enum Foo { - A = Infinity, - B = -Infinity -} -export declare const m: Infinity; - - -//// [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'? - \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity2.symbols b/tests/baselines/reference/fakeInfinity2.symbols deleted file mode 100644 index 3071165542447..0000000000000 --- a/tests/baselines/reference/fakeInfinity2.symbols +++ /dev/null @@ -1,37 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -=== fakeInfinity2.ts === -export enum Foo { ->Foo : Symbol(Foo, Decl(fakeInfinity2.ts, 0, 0)) - - A = 1e999, ->A : Symbol(Foo.A, Decl(fakeInfinity2.ts, 0, 17)) - - B = -1e999, ->B : Symbol(Foo.B, Decl(fakeInfinity2.ts, 1, 14)) -} - -namespace X { ->X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) - - type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) - - type B = 2e999; ->B : Symbol(B, Decl(fakeInfinity2.ts, 6, 19)) - - export function f(): A { ->f : Symbol(f, Decl(fakeInfinity2.ts, 7, 19)) ->A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) - - throw new Error() ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - } -} - -export const m = X.f(); ->m : Symbol(m, Decl(fakeInfinity2.ts, 14, 12)) ->X.f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) ->X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) ->f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) - diff --git a/tests/baselines/reference/fakeInfinity2.types b/tests/baselines/reference/fakeInfinity2.types deleted file mode 100644 index 0303d2c1d1ef6..0000000000000 --- a/tests/baselines/reference/fakeInfinity2.types +++ /dev/null @@ -1,41 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -=== fakeInfinity2.ts === -export enum Foo { ->Foo : Foo - - A = 1e999, ->A : Foo.A ->1e999 : Infinity - - B = -1e999, ->B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity -} - -namespace X { ->X : typeof X - - type A = 1e999; ->A : Infinity - - type B = 2e999; ->B : Infinity - - export function f(): A { ->f : () => Infinity - - throw new Error() ->new Error() : Error ->Error : ErrorConstructor - } -} - -export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity ->X : typeof X ->f : () => Infinity - diff --git a/tests/baselines/reference/fakeInfinity3.js b/tests/baselines/reference/fakeInfinity3.js deleted file mode 100644 index dbde9c2ce72b8..0000000000000 --- a/tests/baselines/reference/fakeInfinity3.js +++ /dev/null @@ -1,70 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -//// [fakeInfinity3.ts] -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); - -export const Infinity = "oops"; - - -//// [fakeInfinity3.js] -"use strict"; -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 || (exports.Foo = Foo = {})); -var X; -(function (X) { - function f() { - throw new Error(); - } - X.f = f; -})(X || (X = {})); -exports.m = X.f(); -exports.Infinity = "oops"; - - -//// [fakeInfinity3.d.ts] -export declare enum Foo { - A = Infinity, - B = -Infinity -} -export declare const m: Infinity; -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/tests/baselines/reference/fakeInfinity3.symbols b/tests/baselines/reference/fakeInfinity3.symbols deleted file mode 100644 index 670ef0ee6521c..0000000000000 --- a/tests/baselines/reference/fakeInfinity3.symbols +++ /dev/null @@ -1,40 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -=== fakeInfinity3.ts === -export enum Foo { ->Foo : Symbol(Foo, Decl(fakeInfinity3.ts, 0, 0)) - - A = 1e999, ->A : Symbol(Foo.A, Decl(fakeInfinity3.ts, 0, 17)) - - B = -1e999, ->B : Symbol(Foo.B, Decl(fakeInfinity3.ts, 1, 14)) -} - -namespace X { ->X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) - - type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) - - type B = 2e999; ->B : Symbol(B, Decl(fakeInfinity3.ts, 6, 19)) - - export function f(): A { ->f : Symbol(f, Decl(fakeInfinity3.ts, 7, 19)) ->A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) - - throw new Error() ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - } -} - -export const m = X.f(); ->m : Symbol(m, Decl(fakeInfinity3.ts, 14, 12)) ->X.f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) ->X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) ->f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) - -export const Infinity = "oops"; ->Infinity : Symbol(Infinity, Decl(fakeInfinity3.ts, 16, 12)) - diff --git a/tests/baselines/reference/fakeInfinity3.types b/tests/baselines/reference/fakeInfinity3.types deleted file mode 100644 index 30eb4d11a9a62..0000000000000 --- a/tests/baselines/reference/fakeInfinity3.types +++ /dev/null @@ -1,45 +0,0 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -=== fakeInfinity3.ts === -export enum Foo { ->Foo : Foo - - A = 1e999, ->A : Foo.A ->1e999 : Infinity - - B = -1e999, ->B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity -} - -namespace X { ->X : typeof X - - type A = 1e999; ->A : Infinity - - type B = 2e999; ->B : Infinity - - export function f(): A { ->f : () => Infinity - - throw new Error() ->new Error() : Error ->Error : ErrorConstructor - } -} - -export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity ->X : typeof X ->f : () => Infinity - -export const Infinity = "oops"; ->Infinity : "oops" ->"oops" : "oops" - diff --git a/tests/baselines/reference/octalIntegerLiteral.types b/tests/baselines/reference/octalIntegerLiteral.types index 4d50a08d194f5..4ab8535089765 100644 --- a/tests/baselines/reference/octalIntegerLiteral.types +++ b/tests/baselines/reference/octalIntegerLiteral.types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number diff --git a/tests/baselines/reference/octalIntegerLiteralES6.types b/tests/baselines/reference/octalIntegerLiteralES6.types index d881232403701..45d9594d93f8c 100644 --- a/tests/baselines/reference/octalIntegerLiteralES6.types +++ b/tests/baselines/reference/octalIntegerLiteralES6.types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number diff --git a/tests/cases/compiler/fakeInfinity1.ts b/tests/cases/compiler/fakeInfinity1.ts deleted file mode 100644 index 06fd705a6a248..0000000000000 --- a/tests/cases/compiler/fakeInfinity1.ts +++ /dev/null @@ -1,25 +0,0 @@ -// @strict: true -// @declaration: true - -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; -export type NegativeInfinity = -1e999; - -export type TypeOfInfinity = typeof Infinity; -export type TypeOfNaN = typeof NaN; - -type A = 1e999; -type B = 1e9999; - -declare let a: A; -declare let b: B; - -a = b; -b = a; - -a = Infinity; -a = 1e999; -a = 1e9999; - -export type Oops = 123456789123456789123456789123456789123456789123456789; -export const oops = 123456789123456789123456789123456789123456789123456789; diff --git a/tests/cases/compiler/fakeInfinity2.ts b/tests/cases/compiler/fakeInfinity2.ts deleted file mode 100644 index a2666a5be527a..0000000000000 --- a/tests/cases/compiler/fakeInfinity2.ts +++ /dev/null @@ -1,18 +0,0 @@ -// @strict: true -// @declaration: true - -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); diff --git a/tests/cases/compiler/fakeInfinity3.ts b/tests/cases/compiler/fakeInfinity3.ts deleted file mode 100644 index 536a48e477e0e..0000000000000 --- a/tests/cases/compiler/fakeInfinity3.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @strict: true -// @declaration: true - -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); - -export const Infinity = "oops"; From 94dcd89ad694cc531768432b3b82b3e89dedff1c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:17:33 -0800 Subject: [PATCH 2/6] Add tests from design meeting --- .../reference/fakeInfinity1.errors.txt | 29 ++++++++ tests/baselines/reference/fakeInfinity1.js | 46 ++++++++++++ .../baselines/reference/fakeInfinity1.symbols | 56 +++++++++++++++ tests/baselines/reference/fakeInfinity1.types | 64 +++++++++++++++++ tests/baselines/reference/fakeInfinity2.js | 62 ++++++++++++++++ .../baselines/reference/fakeInfinity2.symbols | 37 ++++++++++ tests/baselines/reference/fakeInfinity2.types | 41 +++++++++++ tests/baselines/reference/fakeInfinity3.js | 70 +++++++++++++++++++ .../baselines/reference/fakeInfinity3.symbols | 40 +++++++++++ tests/baselines/reference/fakeInfinity3.types | 45 ++++++++++++ tests/cases/compiler/fakeInfinity1.ts | 25 +++++++ tests/cases/compiler/fakeInfinity2.ts | 18 +++++ tests/cases/compiler/fakeInfinity3.ts | 20 ++++++ 13 files changed, 553 insertions(+) create mode 100644 tests/baselines/reference/fakeInfinity1.errors.txt create mode 100644 tests/baselines/reference/fakeInfinity1.js create mode 100644 tests/baselines/reference/fakeInfinity1.symbols create mode 100644 tests/baselines/reference/fakeInfinity1.types create mode 100644 tests/baselines/reference/fakeInfinity2.js create mode 100644 tests/baselines/reference/fakeInfinity2.symbols create mode 100644 tests/baselines/reference/fakeInfinity2.types create mode 100644 tests/baselines/reference/fakeInfinity3.js create mode 100644 tests/baselines/reference/fakeInfinity3.symbols create mode 100644 tests/baselines/reference/fakeInfinity3.types create mode 100644 tests/cases/compiler/fakeInfinity1.ts create mode 100644 tests/cases/compiler/fakeInfinity2.ts create mode 100644 tests/cases/compiler/fakeInfinity3.ts diff --git a/tests/baselines/reference/fakeInfinity1.errors.txt b/tests/baselines/reference/fakeInfinity1.errors.txt new file mode 100644 index 0000000000000..dadb9c68e7dcc --- /dev/null +++ b/tests/baselines/reference/fakeInfinity1.errors.txt @@ -0,0 +1,29 @@ +fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'. + + +==== fakeInfinity1.ts (1 errors) ==== + // These are not actually the real infinity. + export type PositiveInfinity = 1e999; + export type NegativeInfinity = -1e999; + + export type TypeOfInfinity = typeof Infinity; + export type TypeOfNaN = typeof NaN; + + type A = 1e999; + type B = 1e9999; + + declare let a: A; + declare let b: B; + + a = b; + b = a; + + a = Infinity; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'Infinity'. + a = 1e999; + a = 1e9999; + + export type Oops = 123456789123456789123456789123456789123456789123456789; + export const oops = 123456789123456789123456789123456789123456789123456789; + \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity1.js b/tests/baselines/reference/fakeInfinity1.js new file mode 100644 index 0000000000000..eaf4065227f7b --- /dev/null +++ b/tests/baselines/reference/fakeInfinity1.js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +//// [fakeInfinity1.ts] +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +export type NegativeInfinity = -1e999; + +export type TypeOfInfinity = typeof Infinity; +export type TypeOfNaN = typeof NaN; + +type A = 1e999; +type B = 1e9999; + +declare let a: A; +declare let b: B; + +a = b; +b = a; + +a = Infinity; +a = 1e999; +a = 1e9999; + +export type Oops = 123456789123456789123456789123456789123456789123456789; +export const oops = 123456789123456789123456789123456789123456789123456789; + + +//// [fakeInfinity1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.oops = void 0; +a = b; +b = a; +a = Infinity; +a = 1e999; +a = 1e9999; +exports.oops = 123456789123456789123456789123456789123456789123456789; + + +//// [fakeInfinity1.d.ts] +export type PositiveInfinity = 1e999; +export type NegativeInfinity = -1e999; +export type TypeOfInfinity = typeof Infinity; +export type TypeOfNaN = typeof NaN; +export type Oops = 123456789123456789123456789123456789123456789123456789; +export declare const oops = 1.2345678912345678e+53; diff --git a/tests/baselines/reference/fakeInfinity1.symbols b/tests/baselines/reference/fakeInfinity1.symbols new file mode 100644 index 0000000000000..aa37311a823f8 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity1.symbols @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +=== fakeInfinity1.ts === +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +>PositiveInfinity : Symbol(PositiveInfinity, Decl(fakeInfinity1.ts, 0, 0)) + +export type NegativeInfinity = -1e999; +>NegativeInfinity : Symbol(NegativeInfinity, Decl(fakeInfinity1.ts, 1, 37)) + +export type TypeOfInfinity = typeof Infinity; +>TypeOfInfinity : Symbol(TypeOfInfinity, Decl(fakeInfinity1.ts, 2, 38)) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +export type TypeOfNaN = typeof NaN; +>TypeOfNaN : Symbol(TypeOfNaN, Decl(fakeInfinity1.ts, 4, 45)) +>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) + +type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) + +type B = 1e9999; +>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) + +declare let a: A; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) + +declare let b: B; +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) +>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) + +a = b; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) + +b = a; +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +a = Infinity; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +a = 1e999; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +a = 1e9999; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +export type Oops = 123456789123456789123456789123456789123456789123456789; +>Oops : Symbol(Oops, Decl(fakeInfinity1.ts, 18, 11)) + +export const oops = 123456789123456789123456789123456789123456789123456789; +>oops : Symbol(oops, Decl(fakeInfinity1.ts, 21, 12)) + diff --git a/tests/baselines/reference/fakeInfinity1.types b/tests/baselines/reference/fakeInfinity1.types new file mode 100644 index 0000000000000..65e8073401db6 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity1.types @@ -0,0 +1,64 @@ +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +=== fakeInfinity1.ts === +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +>PositiveInfinity : Infinity + +export type NegativeInfinity = -1e999; +>NegativeInfinity : -Infinity +>-1e999 : -Infinity +>1e999 : Infinity + +export type TypeOfInfinity = typeof Infinity; +>TypeOfInfinity : number +>Infinity : number + +export type TypeOfNaN = typeof NaN; +>TypeOfNaN : number +>NaN : number + +type A = 1e999; +>A : Infinity + +type B = 1e9999; +>B : Infinity + +declare let a: A; +>a : Infinity + +declare let b: B; +>b : Infinity + +a = b; +>a = b : Infinity +>a : Infinity +>b : Infinity + +b = a; +>b = a : Infinity +>b : Infinity +>a : Infinity + +a = Infinity; +>a = Infinity : number +>a : Infinity +>Infinity : number + +a = 1e999; +>a = 1e999 : Infinity +>a : Infinity +>1e999 : Infinity + +a = 1e9999; +>a = 1e9999 : Infinity +>a : Infinity +>1e9999 : Infinity + +export type Oops = 123456789123456789123456789123456789123456789123456789; +>Oops : 1.2345678912345678e+53 + +export const oops = 123456789123456789123456789123456789123456789123456789; +>oops : 1.2345678912345678e+53 +>123456789123456789123456789123456789123456789123456789 : 1.2345678912345678e+53 + diff --git a/tests/baselines/reference/fakeInfinity2.js b/tests/baselines/reference/fakeInfinity2.js new file mode 100644 index 0000000000000..2c38e94845d62 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity2.js @@ -0,0 +1,62 @@ +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +//// [fakeInfinity2.ts] +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); + + +//// [fakeInfinity2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.m = exports.Foo = void 0; +var Foo; +(function (Foo) { + Foo[Foo["A"] = Infinity] = "A"; + Foo[Foo["B"] = -Infinity] = "B"; +})(Foo || (exports.Foo = Foo = {})); +var X; +(function (X) { + function f() { + throw new Error(); + } + X.f = f; +})(X || (X = {})); +exports.m = X.f(); + + +//// [fakeInfinity2.d.ts] +export declare enum Foo { + A = Infinity, + B = -Infinity +} +export declare const m: Infinity; + + +//// [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'? + \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity2.symbols b/tests/baselines/reference/fakeInfinity2.symbols new file mode 100644 index 0000000000000..1eb472dfa4433 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity2.symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +=== fakeInfinity2.ts === +export enum Foo { +>Foo : Symbol(Foo, Decl(fakeInfinity2.ts, 0, 0)) + + A = 1e999, +>A : Symbol(Foo.A, Decl(fakeInfinity2.ts, 0, 17)) + + B = -1e999, +>B : Symbol(Foo.B, Decl(fakeInfinity2.ts, 1, 14)) +} + +namespace X { +>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) + + type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) + + type B = 2e999; +>B : Symbol(B, Decl(fakeInfinity2.ts, 6, 19)) + + export function f(): A { +>f : Symbol(f, Decl(fakeInfinity2.ts, 7, 19)) +>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) + + throw new Error() +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +export const m = X.f(); +>m : Symbol(m, Decl(fakeInfinity2.ts, 14, 12)) +>X.f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) +>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) +>f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) + diff --git a/tests/baselines/reference/fakeInfinity2.types b/tests/baselines/reference/fakeInfinity2.types new file mode 100644 index 0000000000000..6b6a449425d0f --- /dev/null +++ b/tests/baselines/reference/fakeInfinity2.types @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +=== fakeInfinity2.ts === +export enum Foo { +>Foo : Foo + + A = 1e999, +>A : Foo.A +>1e999 : Infinity + + B = -1e999, +>B : Foo.B +>-1e999 : -Infinity +>1e999 : Infinity +} + +namespace X { +>X : typeof X + + type A = 1e999; +>A : Infinity + + type B = 2e999; +>B : Infinity + + export function f(): A { +>f : () => Infinity + + throw new Error() +>new Error() : Error +>Error : ErrorConstructor + } +} + +export const m = X.f(); +>m : Infinity +>X.f() : Infinity +>X.f : () => Infinity +>X : typeof X +>f : () => Infinity + diff --git a/tests/baselines/reference/fakeInfinity3.js b/tests/baselines/reference/fakeInfinity3.js new file mode 100644 index 0000000000000..98a66c90dc621 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity3.js @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +//// [fakeInfinity3.ts] +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); + +export const Infinity = "oops"; + + +//// [fakeInfinity3.js] +"use strict"; +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 || (exports.Foo = Foo = {})); +var X; +(function (X) { + function f() { + throw new Error(); + } + X.f = f; +})(X || (X = {})); +exports.m = X.f(); +exports.Infinity = "oops"; + + +//// [fakeInfinity3.d.ts] +export declare enum Foo { + A = Infinity, + B = -Infinity +} +export declare const m: Infinity; +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/tests/baselines/reference/fakeInfinity3.symbols b/tests/baselines/reference/fakeInfinity3.symbols new file mode 100644 index 0000000000000..6f433aaca601b --- /dev/null +++ b/tests/baselines/reference/fakeInfinity3.symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +=== fakeInfinity3.ts === +export enum Foo { +>Foo : Symbol(Foo, Decl(fakeInfinity3.ts, 0, 0)) + + A = 1e999, +>A : Symbol(Foo.A, Decl(fakeInfinity3.ts, 0, 17)) + + B = -1e999, +>B : Symbol(Foo.B, Decl(fakeInfinity3.ts, 1, 14)) +} + +namespace X { +>X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) + + type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) + + type B = 2e999; +>B : Symbol(B, Decl(fakeInfinity3.ts, 6, 19)) + + export function f(): A { +>f : Symbol(f, Decl(fakeInfinity3.ts, 7, 19)) +>A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) + + throw new Error() +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +export const m = X.f(); +>m : Symbol(m, Decl(fakeInfinity3.ts, 14, 12)) +>X.f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) +>X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) +>f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) + +export const Infinity = "oops"; +>Infinity : Symbol(Infinity, Decl(fakeInfinity3.ts, 16, 12)) + diff --git a/tests/baselines/reference/fakeInfinity3.types b/tests/baselines/reference/fakeInfinity3.types new file mode 100644 index 0000000000000..36492022e2114 --- /dev/null +++ b/tests/baselines/reference/fakeInfinity3.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +=== fakeInfinity3.ts === +export enum Foo { +>Foo : Foo + + A = 1e999, +>A : Foo.A +>1e999 : Infinity + + B = -1e999, +>B : Foo.B +>-1e999 : -Infinity +>1e999 : Infinity +} + +namespace X { +>X : typeof X + + type A = 1e999; +>A : Infinity + + type B = 2e999; +>B : Infinity + + export function f(): A { +>f : () => Infinity + + throw new Error() +>new Error() : Error +>Error : ErrorConstructor + } +} + +export const m = X.f(); +>m : Infinity +>X.f() : Infinity +>X.f : () => Infinity +>X : typeof X +>f : () => Infinity + +export const Infinity = "oops"; +>Infinity : "oops" +>"oops" : "oops" + diff --git a/tests/cases/compiler/fakeInfinity1.ts b/tests/cases/compiler/fakeInfinity1.ts new file mode 100644 index 0000000000000..05afe4d779e46 --- /dev/null +++ b/tests/cases/compiler/fakeInfinity1.ts @@ -0,0 +1,25 @@ +// @strict: true +// @declaration: true + +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +export type NegativeInfinity = -1e999; + +export type TypeOfInfinity = typeof Infinity; +export type TypeOfNaN = typeof NaN; + +type A = 1e999; +type B = 1e9999; + +declare let a: A; +declare let b: B; + +a = b; +b = a; + +a = Infinity; +a = 1e999; +a = 1e9999; + +export type Oops = 123456789123456789123456789123456789123456789123456789; +export const oops = 123456789123456789123456789123456789123456789123456789; diff --git a/tests/cases/compiler/fakeInfinity2.ts b/tests/cases/compiler/fakeInfinity2.ts new file mode 100644 index 0000000000000..1e89fb40a269a --- /dev/null +++ b/tests/cases/compiler/fakeInfinity2.ts @@ -0,0 +1,18 @@ +// @strict: true +// @declaration: true + +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); diff --git a/tests/cases/compiler/fakeInfinity3.ts b/tests/cases/compiler/fakeInfinity3.ts new file mode 100644 index 0000000000000..65fe44dc754d5 --- /dev/null +++ b/tests/cases/compiler/fakeInfinity3.ts @@ -0,0 +1,20 @@ +// @strict: true +// @declaration: true + +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); + +export const Infinity = "oops"; From 88b3b54e3a8b8596815d84d9de8e3e8c7b9c394f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 28 Nov 2023 08:22:13 +0100 Subject: [PATCH 3/6] Continue creating number literal types with `Infinity` values --- src/compiler/checker.ts | 9 +- .../reference/binaryIntegerLiteral.types | 2 +- .../reference/binaryIntegerLiteralES6.types | 2 +- .../reference/fakeInfinity1.errors.txt | 56 ++++---- tests/baselines/reference/fakeInfinity1.js | 48 +++---- .../baselines/reference/fakeInfinity1.symbols | 112 +++++++-------- tests/baselines/reference/fakeInfinity1.types | 128 +++++++++--------- tests/baselines/reference/fakeInfinity2.js | 92 ++++++------- .../baselines/reference/fakeInfinity2.symbols | 74 +++++----- tests/baselines/reference/fakeInfinity2.types | 82 +++++------ tests/baselines/reference/fakeInfinity3.js | 104 +++++++------- .../baselines/reference/fakeInfinity3.symbols | 80 +++++------ tests/baselines/reference/fakeInfinity3.types | 90 ++++++------ .../reference/octalIntegerLiteral.types | 2 +- .../reference/octalIntegerLiteralES6.types | 2 +- 15 files changed, 439 insertions(+), 444 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c22cbfc6a6a6..983c55eaf456f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -39021,14 +39021,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return hasSkipDirectInferenceFlag(node) ? blockedStringType : getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text)); - case SyntaxKind.NumericLiteral: { + case SyntaxKind.NumericLiteral: checkGrammarNumericLiteral(node as NumericLiteral); - const value = +(node as NumericLiteral).text; - if (!isFinite(value)) { - return numberType; - } - return getFreshTypeOfLiteralType(getNumberLiteralType(value)); - } + return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text)); case SyntaxKind.BigIntLiteral: checkGrammarBigIntLiteral(node as BigIntLiteral); return getFreshTypeOfLiteralType(getBigIntLiteralType({ diff --git a/tests/baselines/reference/binaryIntegerLiteral.types b/tests/baselines/reference/binaryIntegerLiteral.types index 48b9d9532cc1a..2c81595c0c8b4 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.types +++ b/tests/baselines/reference/binaryIntegerLiteral.types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.types b/tests/baselines/reference/binaryIntegerLiteralES6.types index 8b6d7437affd4..2abc7ca72ca22 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.types +++ b/tests/baselines/reference/binaryIntegerLiteralES6.types @@ -15,7 +15,7 @@ var bin3 = 0B1111111111111111111111111111111111111111111111110100101010000001011 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity var obj1 = { >obj1 : { 26: string; a: number; bin1: number; b: number; Infinity: boolean; } diff --git a/tests/baselines/reference/fakeInfinity1.errors.txt b/tests/baselines/reference/fakeInfinity1.errors.txt index dadb9c68e7dcc..52fd2751609ed 100644 --- a/tests/baselines/reference/fakeInfinity1.errors.txt +++ b/tests/baselines/reference/fakeInfinity1.errors.txt @@ -1,29 +1,29 @@ -fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'. - - -==== fakeInfinity1.ts (1 errors) ==== - // These are not actually the real infinity. - export type PositiveInfinity = 1e999; - export type NegativeInfinity = -1e999; - - export type TypeOfInfinity = typeof Infinity; - export type TypeOfNaN = typeof NaN; - - type A = 1e999; - type B = 1e9999; - - declare let a: A; - declare let b: B; - - a = b; - b = a; - - a = Infinity; - ~ -!!! error TS2322: Type 'number' is not assignable to type 'Infinity'. - a = 1e999; - a = 1e9999; - - export type Oops = 123456789123456789123456789123456789123456789123456789; - export const oops = 123456789123456789123456789123456789123456789123456789; +fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'. + + +==== fakeInfinity1.ts (1 errors) ==== + // These are not actually the real infinity. + export type PositiveInfinity = 1e999; + export type NegativeInfinity = -1e999; + + export type TypeOfInfinity = typeof Infinity; + export type TypeOfNaN = typeof NaN; + + type A = 1e999; + type B = 1e9999; + + declare let a: A; + declare let b: B; + + a = b; + b = a; + + a = Infinity; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'Infinity'. + a = 1e999; + a = 1e9999; + + export type Oops = 123456789123456789123456789123456789123456789123456789; + export const oops = 123456789123456789123456789123456789123456789123456789; \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity1.js b/tests/baselines/reference/fakeInfinity1.js index eaf4065227f7b..c28497a9fa3a0 100644 --- a/tests/baselines/reference/fakeInfinity1.js +++ b/tests/baselines/reference/fakeInfinity1.js @@ -1,6 +1,6 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -//// [fakeInfinity1.ts] +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +//// [fakeInfinity1.ts] // These are not actually the real infinity. export type PositiveInfinity = 1e999; export type NegativeInfinity = -1e999; @@ -23,24 +23,24 @@ a = 1e9999; export type Oops = 123456789123456789123456789123456789123456789123456789; export const oops = 123456789123456789123456789123456789123456789123456789; - - -//// [fakeInfinity1.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.oops = void 0; -a = b; -b = a; -a = Infinity; -a = 1e999; -a = 1e9999; -exports.oops = 123456789123456789123456789123456789123456789123456789; - - -//// [fakeInfinity1.d.ts] -export type PositiveInfinity = 1e999; -export type NegativeInfinity = -1e999; -export type TypeOfInfinity = typeof Infinity; -export type TypeOfNaN = typeof NaN; -export type Oops = 123456789123456789123456789123456789123456789123456789; -export declare const oops = 1.2345678912345678e+53; + + +//// [fakeInfinity1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.oops = void 0; +a = b; +b = a; +a = Infinity; +a = 1e999; +a = 1e9999; +exports.oops = 123456789123456789123456789123456789123456789123456789; + + +//// [fakeInfinity1.d.ts] +export type PositiveInfinity = 1e999; +export type NegativeInfinity = -1e999; +export type TypeOfInfinity = typeof Infinity; +export type TypeOfNaN = typeof NaN; +export type Oops = 123456789123456789123456789123456789123456789123456789; +export declare const oops = 1.2345678912345678e+53; diff --git a/tests/baselines/reference/fakeInfinity1.symbols b/tests/baselines/reference/fakeInfinity1.symbols index aa37311a823f8..07cb183dae865 100644 --- a/tests/baselines/reference/fakeInfinity1.symbols +++ b/tests/baselines/reference/fakeInfinity1.symbols @@ -1,56 +1,56 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -=== fakeInfinity1.ts === -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; ->PositiveInfinity : Symbol(PositiveInfinity, Decl(fakeInfinity1.ts, 0, 0)) - -export type NegativeInfinity = -1e999; ->NegativeInfinity : Symbol(NegativeInfinity, Decl(fakeInfinity1.ts, 1, 37)) - -export type TypeOfInfinity = typeof Infinity; ->TypeOfInfinity : Symbol(TypeOfInfinity, Decl(fakeInfinity1.ts, 2, 38)) ->Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) - -export type TypeOfNaN = typeof NaN; ->TypeOfNaN : Symbol(TypeOfNaN, Decl(fakeInfinity1.ts, 4, 45)) ->NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) - -type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) - -type B = 1e9999; ->B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) - -declare let a: A; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) - -declare let b: B; ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) ->B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) - -a = b; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) - -b = a; ->b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -a = Infinity; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) ->Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) - -a = 1e999; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -a = 1e9999; ->a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) - -export type Oops = 123456789123456789123456789123456789123456789123456789; ->Oops : Symbol(Oops, Decl(fakeInfinity1.ts, 18, 11)) - -export const oops = 123456789123456789123456789123456789123456789123456789; ->oops : Symbol(oops, Decl(fakeInfinity1.ts, 21, 12)) - +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +=== fakeInfinity1.ts === +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +>PositiveInfinity : Symbol(PositiveInfinity, Decl(fakeInfinity1.ts, 0, 0)) + +export type NegativeInfinity = -1e999; +>NegativeInfinity : Symbol(NegativeInfinity, Decl(fakeInfinity1.ts, 1, 37)) + +export type TypeOfInfinity = typeof Infinity; +>TypeOfInfinity : Symbol(TypeOfInfinity, Decl(fakeInfinity1.ts, 2, 38)) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +export type TypeOfNaN = typeof NaN; +>TypeOfNaN : Symbol(TypeOfNaN, Decl(fakeInfinity1.ts, 4, 45)) +>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) + +type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) + +type B = 1e9999; +>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) + +declare let a: A; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35)) + +declare let b: B; +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) +>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15)) + +a = b; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) + +b = a; +>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11)) +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +a = Infinity; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +a = 1e999; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +a = 1e9999; +>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11)) + +export type Oops = 123456789123456789123456789123456789123456789123456789; +>Oops : Symbol(Oops, Decl(fakeInfinity1.ts, 18, 11)) + +export const oops = 123456789123456789123456789123456789123456789123456789; +>oops : Symbol(oops, Decl(fakeInfinity1.ts, 21, 12)) + diff --git a/tests/baselines/reference/fakeInfinity1.types b/tests/baselines/reference/fakeInfinity1.types index 65e8073401db6..0d5f3d1aa4f37 100644 --- a/tests/baselines/reference/fakeInfinity1.types +++ b/tests/baselines/reference/fakeInfinity1.types @@ -1,64 +1,64 @@ -//// [tests/cases/compiler/fakeInfinity1.ts] //// - -=== fakeInfinity1.ts === -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; ->PositiveInfinity : Infinity - -export type NegativeInfinity = -1e999; ->NegativeInfinity : -Infinity ->-1e999 : -Infinity ->1e999 : Infinity - -export type TypeOfInfinity = typeof Infinity; ->TypeOfInfinity : number ->Infinity : number - -export type TypeOfNaN = typeof NaN; ->TypeOfNaN : number ->NaN : number - -type A = 1e999; ->A : Infinity - -type B = 1e9999; ->B : Infinity - -declare let a: A; ->a : Infinity - -declare let b: B; ->b : Infinity - -a = b; ->a = b : Infinity ->a : Infinity ->b : Infinity - -b = a; ->b = a : Infinity ->b : Infinity ->a : Infinity - -a = Infinity; ->a = Infinity : number ->a : Infinity ->Infinity : number - -a = 1e999; ->a = 1e999 : Infinity ->a : Infinity ->1e999 : Infinity - -a = 1e9999; ->a = 1e9999 : Infinity ->a : Infinity ->1e9999 : Infinity - -export type Oops = 123456789123456789123456789123456789123456789123456789; ->Oops : 1.2345678912345678e+53 - -export const oops = 123456789123456789123456789123456789123456789123456789; ->oops : 1.2345678912345678e+53 ->123456789123456789123456789123456789123456789123456789 : 1.2345678912345678e+53 - +//// [tests/cases/compiler/fakeInfinity1.ts] //// + +=== fakeInfinity1.ts === +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +>PositiveInfinity : Infinity + +export type NegativeInfinity = -1e999; +>NegativeInfinity : -Infinity +>-1e999 : -Infinity +>1e999 : Infinity + +export type TypeOfInfinity = typeof Infinity; +>TypeOfInfinity : number +>Infinity : number + +export type TypeOfNaN = typeof NaN; +>TypeOfNaN : number +>NaN : number + +type A = 1e999; +>A : Infinity + +type B = 1e9999; +>B : Infinity + +declare let a: A; +>a : Infinity + +declare let b: B; +>b : Infinity + +a = b; +>a = b : Infinity +>a : Infinity +>b : Infinity + +b = a; +>b = a : Infinity +>b : Infinity +>a : Infinity + +a = Infinity; +>a = Infinity : number +>a : Infinity +>Infinity : number + +a = 1e999; +>a = 1e999 : Infinity +>a : Infinity +>1e999 : Infinity + +a = 1e9999; +>a = 1e9999 : Infinity +>a : Infinity +>1e9999 : Infinity + +export type Oops = 123456789123456789123456789123456789123456789123456789; +>Oops : 1.2345678912345678e+53 + +export const oops = 123456789123456789123456789123456789123456789123456789; +>oops : 1.2345678912345678e+53 +>123456789123456789123456789123456789123456789123456789 : 1.2345678912345678e+53 + diff --git a/tests/baselines/reference/fakeInfinity2.js b/tests/baselines/reference/fakeInfinity2.js index 2c38e94845d62..779b0f421d988 100644 --- a/tests/baselines/reference/fakeInfinity2.js +++ b/tests/baselines/reference/fakeInfinity2.js @@ -1,6 +1,6 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -//// [fakeInfinity2.ts] +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +//// [fakeInfinity2.ts] export enum Foo { A = 1e999, B = -1e999, @@ -16,47 +16,47 @@ namespace X { } export const m = X.f(); - - -//// [fakeInfinity2.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.m = exports.Foo = void 0; -var Foo; -(function (Foo) { - Foo[Foo["A"] = Infinity] = "A"; - Foo[Foo["B"] = -Infinity] = "B"; -})(Foo || (exports.Foo = Foo = {})); -var X; -(function (X) { - function f() { - throw new Error(); - } - X.f = f; -})(X || (X = {})); -exports.m = X.f(); - - -//// [fakeInfinity2.d.ts] -export declare enum Foo { - A = Infinity, - B = -Infinity -} -export declare const m: Infinity; - - -//// [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'? + + +//// [fakeInfinity2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.m = exports.Foo = void 0; +var Foo; +(function (Foo) { + Foo[Foo["A"] = Infinity] = "A"; + Foo[Foo["B"] = -Infinity] = "B"; +})(Foo || (exports.Foo = Foo = {})); +var X; +(function (X) { + function f() { + throw new Error(); + } + X.f = f; +})(X || (X = {})); +exports.m = X.f(); + + +//// [fakeInfinity2.d.ts] +export declare enum Foo { + A = Infinity, + B = -Infinity +} +export declare const m: Infinity; + + +//// [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'? \ No newline at end of file diff --git a/tests/baselines/reference/fakeInfinity2.symbols b/tests/baselines/reference/fakeInfinity2.symbols index 1eb472dfa4433..3071165542447 100644 --- a/tests/baselines/reference/fakeInfinity2.symbols +++ b/tests/baselines/reference/fakeInfinity2.symbols @@ -1,37 +1,37 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -=== fakeInfinity2.ts === -export enum Foo { ->Foo : Symbol(Foo, Decl(fakeInfinity2.ts, 0, 0)) - - A = 1e999, ->A : Symbol(Foo.A, Decl(fakeInfinity2.ts, 0, 17)) - - B = -1e999, ->B : Symbol(Foo.B, Decl(fakeInfinity2.ts, 1, 14)) -} - -namespace X { ->X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) - - type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) - - type B = 2e999; ->B : Symbol(B, Decl(fakeInfinity2.ts, 6, 19)) - - export function f(): A { ->f : Symbol(f, Decl(fakeInfinity2.ts, 7, 19)) ->A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) - - throw new Error() ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - } -} - -export const m = X.f(); ->m : Symbol(m, Decl(fakeInfinity2.ts, 14, 12)) ->X.f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) ->X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) ->f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) - +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +=== fakeInfinity2.ts === +export enum Foo { +>Foo : Symbol(Foo, Decl(fakeInfinity2.ts, 0, 0)) + + A = 1e999, +>A : Symbol(Foo.A, Decl(fakeInfinity2.ts, 0, 17)) + + B = -1e999, +>B : Symbol(Foo.B, Decl(fakeInfinity2.ts, 1, 14)) +} + +namespace X { +>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) + + type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) + + type B = 2e999; +>B : Symbol(B, Decl(fakeInfinity2.ts, 6, 19)) + + export function f(): A { +>f : Symbol(f, Decl(fakeInfinity2.ts, 7, 19)) +>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13)) + + throw new Error() +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +export const m = X.f(); +>m : Symbol(m, Decl(fakeInfinity2.ts, 14, 12)) +>X.f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) +>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1)) +>f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19)) + diff --git a/tests/baselines/reference/fakeInfinity2.types b/tests/baselines/reference/fakeInfinity2.types index 6b6a449425d0f..0303d2c1d1ef6 100644 --- a/tests/baselines/reference/fakeInfinity2.types +++ b/tests/baselines/reference/fakeInfinity2.types @@ -1,41 +1,41 @@ -//// [tests/cases/compiler/fakeInfinity2.ts] //// - -=== fakeInfinity2.ts === -export enum Foo { ->Foo : Foo - - A = 1e999, ->A : Foo.A ->1e999 : Infinity - - B = -1e999, ->B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity -} - -namespace X { ->X : typeof X - - type A = 1e999; ->A : Infinity - - type B = 2e999; ->B : Infinity - - export function f(): A { ->f : () => Infinity - - throw new Error() ->new Error() : Error ->Error : ErrorConstructor - } -} - -export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity ->X : typeof X ->f : () => Infinity - +//// [tests/cases/compiler/fakeInfinity2.ts] //// + +=== fakeInfinity2.ts === +export enum Foo { +>Foo : Foo + + A = 1e999, +>A : Foo.A +>1e999 : Infinity + + B = -1e999, +>B : Foo.B +>-1e999 : -Infinity +>1e999 : Infinity +} + +namespace X { +>X : typeof X + + type A = 1e999; +>A : Infinity + + type B = 2e999; +>B : Infinity + + export function f(): A { +>f : () => Infinity + + throw new Error() +>new Error() : Error +>Error : ErrorConstructor + } +} + +export const m = X.f(); +>m : Infinity +>X.f() : Infinity +>X.f : () => Infinity +>X : typeof X +>f : () => Infinity + diff --git a/tests/baselines/reference/fakeInfinity3.js b/tests/baselines/reference/fakeInfinity3.js index 98a66c90dc621..dbde9c2ce72b8 100644 --- a/tests/baselines/reference/fakeInfinity3.js +++ b/tests/baselines/reference/fakeInfinity3.js @@ -1,6 +1,6 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -//// [fakeInfinity3.ts] +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +//// [fakeInfinity3.ts] export enum Foo { A = 1e999, B = -1e999, @@ -18,53 +18,53 @@ namespace X { export const m = X.f(); export const Infinity = "oops"; - - -//// [fakeInfinity3.js] -"use strict"; -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 || (exports.Foo = Foo = {})); -var X; -(function (X) { - function f() { - throw new Error(); - } - X.f = f; -})(X || (X = {})); -exports.m = X.f(); -exports.Infinity = "oops"; - - -//// [fakeInfinity3.d.ts] -export declare enum Foo { - A = Infinity, - B = -Infinity -} -export declare const m: Infinity; -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"; + + +//// [fakeInfinity3.js] +"use strict"; +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 || (exports.Foo = Foo = {})); +var X; +(function (X) { + function f() { + throw new Error(); + } + X.f = f; +})(X || (X = {})); +exports.m = X.f(); +exports.Infinity = "oops"; + + +//// [fakeInfinity3.d.ts] +export declare enum Foo { + A = Infinity, + B = -Infinity +} +export declare const m: Infinity; +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/tests/baselines/reference/fakeInfinity3.symbols b/tests/baselines/reference/fakeInfinity3.symbols index 6f433aaca601b..670ef0ee6521c 100644 --- a/tests/baselines/reference/fakeInfinity3.symbols +++ b/tests/baselines/reference/fakeInfinity3.symbols @@ -1,40 +1,40 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -=== fakeInfinity3.ts === -export enum Foo { ->Foo : Symbol(Foo, Decl(fakeInfinity3.ts, 0, 0)) - - A = 1e999, ->A : Symbol(Foo.A, Decl(fakeInfinity3.ts, 0, 17)) - - B = -1e999, ->B : Symbol(Foo.B, Decl(fakeInfinity3.ts, 1, 14)) -} - -namespace X { ->X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) - - type A = 1e999; ->A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) - - type B = 2e999; ->B : Symbol(B, Decl(fakeInfinity3.ts, 6, 19)) - - export function f(): A { ->f : Symbol(f, Decl(fakeInfinity3.ts, 7, 19)) ->A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) - - throw new Error() ->Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - } -} - -export const m = X.f(); ->m : Symbol(m, Decl(fakeInfinity3.ts, 14, 12)) ->X.f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) ->X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) ->f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) - -export const Infinity = "oops"; ->Infinity : Symbol(Infinity, Decl(fakeInfinity3.ts, 16, 12)) - +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +=== fakeInfinity3.ts === +export enum Foo { +>Foo : Symbol(Foo, Decl(fakeInfinity3.ts, 0, 0)) + + A = 1e999, +>A : Symbol(Foo.A, Decl(fakeInfinity3.ts, 0, 17)) + + B = -1e999, +>B : Symbol(Foo.B, Decl(fakeInfinity3.ts, 1, 14)) +} + +namespace X { +>X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) + + type A = 1e999; +>A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) + + type B = 2e999; +>B : Symbol(B, Decl(fakeInfinity3.ts, 6, 19)) + + export function f(): A { +>f : Symbol(f, Decl(fakeInfinity3.ts, 7, 19)) +>A : Symbol(A, Decl(fakeInfinity3.ts, 5, 13)) + + throw new Error() +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +export const m = X.f(); +>m : Symbol(m, Decl(fakeInfinity3.ts, 14, 12)) +>X.f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) +>X : Symbol(X, Decl(fakeInfinity3.ts, 3, 1)) +>f : Symbol(X.f, Decl(fakeInfinity3.ts, 7, 19)) + +export const Infinity = "oops"; +>Infinity : Symbol(Infinity, Decl(fakeInfinity3.ts, 16, 12)) + diff --git a/tests/baselines/reference/fakeInfinity3.types b/tests/baselines/reference/fakeInfinity3.types index 36492022e2114..30eb4d11a9a62 100644 --- a/tests/baselines/reference/fakeInfinity3.types +++ b/tests/baselines/reference/fakeInfinity3.types @@ -1,45 +1,45 @@ -//// [tests/cases/compiler/fakeInfinity3.ts] //// - -=== fakeInfinity3.ts === -export enum Foo { ->Foo : Foo - - A = 1e999, ->A : Foo.A ->1e999 : Infinity - - B = -1e999, ->B : Foo.B ->-1e999 : -Infinity ->1e999 : Infinity -} - -namespace X { ->X : typeof X - - type A = 1e999; ->A : Infinity - - type B = 2e999; ->B : Infinity - - export function f(): A { ->f : () => Infinity - - throw new Error() ->new Error() : Error ->Error : ErrorConstructor - } -} - -export const m = X.f(); ->m : Infinity ->X.f() : Infinity ->X.f : () => Infinity ->X : typeof X ->f : () => Infinity - -export const Infinity = "oops"; ->Infinity : "oops" ->"oops" : "oops" - +//// [tests/cases/compiler/fakeInfinity3.ts] //// + +=== fakeInfinity3.ts === +export enum Foo { +>Foo : Foo + + A = 1e999, +>A : Foo.A +>1e999 : Infinity + + B = -1e999, +>B : Foo.B +>-1e999 : -Infinity +>1e999 : Infinity +} + +namespace X { +>X : typeof X + + type A = 1e999; +>A : Infinity + + type B = 2e999; +>B : Infinity + + export function f(): A { +>f : () => Infinity + + throw new Error() +>new Error() : Error +>Error : ErrorConstructor + } +} + +export const m = X.f(); +>m : Infinity +>X.f() : Infinity +>X.f : () => Infinity +>X : typeof X +>f : () => Infinity + +export const Infinity = "oops"; +>Infinity : "oops" +>"oops" : "oops" + diff --git a/tests/baselines/reference/octalIntegerLiteral.types b/tests/baselines/reference/octalIntegerLiteral.types index 4ab8535089765..4d50a08d194f5 100644 --- a/tests/baselines/reference/octalIntegerLiteral.types +++ b/tests/baselines/reference/octalIntegerLiteral.types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number diff --git a/tests/baselines/reference/octalIntegerLiteralES6.types b/tests/baselines/reference/octalIntegerLiteralES6.types index 45d9594d93f8c..d881232403701 100644 --- a/tests/baselines/reference/octalIntegerLiteralES6.types +++ b/tests/baselines/reference/octalIntegerLiteralES6.types @@ -11,7 +11,7 @@ var oct2 = 0O45436; var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number From d2e279cd5e2dd8d857925f50df041f3dc9f489fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 7 Dec 2023 16:50:57 +0100 Subject: [PATCH 4/6] fix line endings --- tests/cases/compiler/fakeInfinity1.ts | 50 +++++++++++++-------------- tests/cases/compiler/fakeInfinity2.ts | 36 +++++++++---------- tests/cases/compiler/fakeInfinity3.ts | 40 ++++++++++----------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/tests/cases/compiler/fakeInfinity1.ts b/tests/cases/compiler/fakeInfinity1.ts index 05afe4d779e46..06fd705a6a248 100644 --- a/tests/cases/compiler/fakeInfinity1.ts +++ b/tests/cases/compiler/fakeInfinity1.ts @@ -1,25 +1,25 @@ -// @strict: true -// @declaration: true - -// These are not actually the real infinity. -export type PositiveInfinity = 1e999; -export type NegativeInfinity = -1e999; - -export type TypeOfInfinity = typeof Infinity; -export type TypeOfNaN = typeof NaN; - -type A = 1e999; -type B = 1e9999; - -declare let a: A; -declare let b: B; - -a = b; -b = a; - -a = Infinity; -a = 1e999; -a = 1e9999; - -export type Oops = 123456789123456789123456789123456789123456789123456789; -export const oops = 123456789123456789123456789123456789123456789123456789; +// @strict: true +// @declaration: true + +// These are not actually the real infinity. +export type PositiveInfinity = 1e999; +export type NegativeInfinity = -1e999; + +export type TypeOfInfinity = typeof Infinity; +export type TypeOfNaN = typeof NaN; + +type A = 1e999; +type B = 1e9999; + +declare let a: A; +declare let b: B; + +a = b; +b = a; + +a = Infinity; +a = 1e999; +a = 1e9999; + +export type Oops = 123456789123456789123456789123456789123456789123456789; +export const oops = 123456789123456789123456789123456789123456789123456789; diff --git a/tests/cases/compiler/fakeInfinity2.ts b/tests/cases/compiler/fakeInfinity2.ts index 1e89fb40a269a..a2666a5be527a 100644 --- a/tests/cases/compiler/fakeInfinity2.ts +++ b/tests/cases/compiler/fakeInfinity2.ts @@ -1,18 +1,18 @@ -// @strict: true -// @declaration: true - -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); +// @strict: true +// @declaration: true + +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); diff --git a/tests/cases/compiler/fakeInfinity3.ts b/tests/cases/compiler/fakeInfinity3.ts index 65fe44dc754d5..536a48e477e0e 100644 --- a/tests/cases/compiler/fakeInfinity3.ts +++ b/tests/cases/compiler/fakeInfinity3.ts @@ -1,20 +1,20 @@ -// @strict: true -// @declaration: true - -export enum Foo { - A = 1e999, - B = -1e999, -} - -namespace X { - type A = 1e999; - type B = 2e999; - - export function f(): A { - throw new Error() - } -} - -export const m = X.f(); - -export const Infinity = "oops"; +// @strict: true +// @declaration: true + +export enum Foo { + A = 1e999, + B = -1e999, +} + +namespace X { + type A = 1e999; + type B = 2e999; + + export function f(): A { + throw new Error() + } +} + +export const m = X.f(); + +export const Infinity = "oops"; From 04bf26aab4afa6422803ff31119f35fabaf8f279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 7 Dec 2023 21:17:05 +0100 Subject: [PATCH 5/6] address PR feedback --- src/compiler/checker.ts | 4 ++-- src/compiler/transformers/declarations.ts | 2 +- src/compiler/transformers/ts.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d12e836ad1671..907fae988c22b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8345,7 +8345,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return factory.createStringLiteral(name, !!singleQuote); } if (isNumericLiteralName(name) && startsWith(name, "-")) { - return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(+name)))); + return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-name))); } return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod); } @@ -48151,7 +48151,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const literalValue = (type as LiteralType).value; return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : typeof literalValue === "string" ? factory.createStringLiteral(literalValue) : - literalValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(literalValue))) : + literalValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-literalValue)) : factory.createNumericLiteral(literalValue); } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 2094911ef14df..429cf5c40b498 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1803,7 +1803,7 @@ export function transformDeclarations(context: TransformationContext) { : typeof constValue === "string" ? factory.createStringLiteral(constValue) : constValue < 0 - ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(constValue))) + ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-constValue)) : factory.createNumericLiteral(constValue); return preserveJsDoc(factory.updateEnumMember(m, m.name, newInitializer), m); })), diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 584cf837e180a..0548a5bf0da9c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1902,7 +1902,7 @@ export function transformTypeScript(context: TransformationContext) { const value = resolver.getConstantValue(member); if (value !== undefined) { return typeof value === "string" ? factory.createStringLiteral(value) : - value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))) : + value < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-value)) : factory.createNumericLiteral(value); } else { @@ -2689,7 +2689,7 @@ export function transformTypeScript(context: TransformationContext) { // track the constant value on the node for the printer in mayNeedDotDotForPropertyAccess setConstantValue(node, constantValue); const substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : - constantValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(constantValue))) : + constantValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-constantValue)) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { From 6cc2219f22725896ee9a312d7304351f754e5c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 7 Dec 2023 23:58:39 +0100 Subject: [PATCH 6/6] tweak code style --- src/compiler/transformers/declarations.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 429cf5c40b498..0f3479133ec55 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1798,12 +1798,9 @@ export function transformDeclarations(context: TransformationContext) { if (shouldStripInternal(m)) return; // Rewrite enum values to their constants, if available const constValue = resolver.getConstantValue(m); - const newInitializer = constValue === undefined - ? undefined - : typeof constValue === "string" - ? factory.createStringLiteral(constValue) - : constValue < 0 - ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-constValue)) + const newInitializer = constValue === undefined ? undefined + : typeof constValue === "string" ? factory.createStringLiteral(constValue) + : constValue < 0 ? factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-constValue)) : factory.createNumericLiteral(constValue); return preserveJsDoc(factory.updateEnumMember(m, m.name, newInitializer), m); })),