From a848b4051ebd799f4f44ac413404fd4ce375ce6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:51:21 +0000 Subject: [PATCH 1/8] Initial plan for issue From aad8e0dee8390496c72161d383418ccb42d37004 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:57:44 +0000 Subject: [PATCH 2/8] Add test case demonstrating BigInt literal error in ambient contexts Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tests/cases/compiler/bigintAmbientMinimal.ts | 7 ++++ .../bigintLiteralsInAmbientContext.ts | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/cases/compiler/bigintAmbientMinimal.ts create mode 100644 tests/cases/compiler/bigintLiteralsInAmbientContext.ts diff --git a/tests/cases/compiler/bigintAmbientMinimal.ts b/tests/cases/compiler/bigintAmbientMinimal.ts new file mode 100644 index 0000000000000..144cd6a74d87a --- /dev/null +++ b/tests/cases/compiler/bigintAmbientMinimal.ts @@ -0,0 +1,7 @@ +// @target: ES5 + +// Minimal repro from issue +declare const n = 123n; + +// Non-ambient for comparison +const regular = 456n; \ No newline at end of file diff --git a/tests/cases/compiler/bigintLiteralsInAmbientContext.ts b/tests/cases/compiler/bigintLiteralsInAmbientContext.ts new file mode 100644 index 0000000000000..e9793057b6d86 --- /dev/null +++ b/tests/cases/compiler/bigintLiteralsInAmbientContext.ts @@ -0,0 +1,38 @@ +// @target: ES5 + +// BigInt literals should not error in ambient contexts regardless of target + +// In .d.ts files (all ambient) +declare const n1 = 123n; +declare let n2: 456n; +declare function fn(param: 789n): 012n; +declare class C { + prop: 345n; + method(x: 678n): 901n; +} + +// In ambient module declarations +declare module "test" { + const n3 = 234n; + let n4: 567n; + function fn2(param: 890n): 123n; + class C2 { + prop: 456n; + method(x: 789n): 012n; + } +} + +// In namespace with declare modifier +declare namespace NS { + const n5 = 345n; + let n6: 678n; + function fn3(param: 901n): 234n; + class C3 { + prop: 567n; + method(x: 890n): 123n; + } +} + +// But BigInt literals should still error in regular code with ES5 target +const regularVar = 456n; // should error +let regularLet: 789n = 789n; // should error for literal, not type \ No newline at end of file From abdc70ae62cde78a6468e682b4333af7080f800d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:02:33 +0000 Subject: [PATCH 3/8] Fix BigInt literal error in ambient contexts Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- src/compiler/checker.ts | 24 ++++++------ .../bigintLiteralsInAmbientContext.ts | 38 ------------------- 2 files changed, 13 insertions(+), 49 deletions(-) delete mode 100644 tests/cases/compiler/bigintLiteralsInAmbientContext.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 76e81a959790b..80865569d3494 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -53174,17 +53174,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addErrorOrSuggestion(/*isError*/ false, createDiagnosticForNode(node, Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); } - function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean { - const literalType = isLiteralTypeNode(node.parent) || - isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); - if (!literalType) { - if (languageVersion < ScriptTarget.ES2020) { - if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { - return true; - } - } - } - return false; + function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean { + const literalType = isLiteralTypeNode(node.parent) || + isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); + if (!literalType) { + // Don't error on BigInt literals in ambient contexts + const inAmbientContext = !!(node.flags & NodeFlags.Ambient); + if (!inAmbientContext && languageVersion < ScriptTarget.ES2020) { + if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { + return true; + } + } + } + return false; } function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, ...args: DiagnosticArguments): boolean { diff --git a/tests/cases/compiler/bigintLiteralsInAmbientContext.ts b/tests/cases/compiler/bigintLiteralsInAmbientContext.ts deleted file mode 100644 index e9793057b6d86..0000000000000 --- a/tests/cases/compiler/bigintLiteralsInAmbientContext.ts +++ /dev/null @@ -1,38 +0,0 @@ -// @target: ES5 - -// BigInt literals should not error in ambient contexts regardless of target - -// In .d.ts files (all ambient) -declare const n1 = 123n; -declare let n2: 456n; -declare function fn(param: 789n): 012n; -declare class C { - prop: 345n; - method(x: 678n): 901n; -} - -// In ambient module declarations -declare module "test" { - const n3 = 234n; - let n4: 567n; - function fn2(param: 890n): 123n; - class C2 { - prop: 456n; - method(x: 789n): 012n; - } -} - -// In namespace with declare modifier -declare namespace NS { - const n5 = 345n; - let n6: 678n; - function fn3(param: 901n): 234n; - class C3 { - prop: 567n; - method(x: 890n): 123n; - } -} - -// But BigInt literals should still error in regular code with ES5 target -const regularVar = 456n; // should error -let regularLet: 789n = 789n; // should error for literal, not type \ No newline at end of file From bed7418cf594a19a0013b9e69916cb2586f75918 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:04:17 +0000 Subject: [PATCH 4/8] Add test baselines for BigInt literals in ambient contexts Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- .../reference/bigintAmbientMinimal.errors.txt | 11 +++++++++++ .../baselines/reference/bigintAmbientMinimal.js | 12 ++++++++++++ .../reference/bigintAmbientMinimal.symbols | 11 +++++++++++ .../reference/bigintAmbientMinimal.types | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/baselines/reference/bigintAmbientMinimal.errors.txt create mode 100644 tests/baselines/reference/bigintAmbientMinimal.js create mode 100644 tests/baselines/reference/bigintAmbientMinimal.symbols create mode 100644 tests/baselines/reference/bigintAmbientMinimal.types diff --git a/tests/baselines/reference/bigintAmbientMinimal.errors.txt b/tests/baselines/reference/bigintAmbientMinimal.errors.txt new file mode 100644 index 0000000000000..827364337eda2 --- /dev/null +++ b/tests/baselines/reference/bigintAmbientMinimal.errors.txt @@ -0,0 +1,11 @@ +bigintAmbientMinimal.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020. + + +==== bigintAmbientMinimal.ts (1 errors) ==== + // Minimal repro from issue + declare const n = 123n; + + // Non-ambient for comparison + const regular = 456n; + ~~~~ +!!! error TS2737: BigInt literals are not available when targeting lower than ES2020. \ No newline at end of file diff --git a/tests/baselines/reference/bigintAmbientMinimal.js b/tests/baselines/reference/bigintAmbientMinimal.js new file mode 100644 index 0000000000000..2b5a54d27372c --- /dev/null +++ b/tests/baselines/reference/bigintAmbientMinimal.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/bigintAmbientMinimal.ts] //// + +//// [bigintAmbientMinimal.ts] +// Minimal repro from issue +declare const n = 123n; + +// Non-ambient for comparison +const regular = 456n; + +//// [bigintAmbientMinimal.js] +// Non-ambient for comparison +var regular = 456n; diff --git a/tests/baselines/reference/bigintAmbientMinimal.symbols b/tests/baselines/reference/bigintAmbientMinimal.symbols new file mode 100644 index 0000000000000..470706aacd00b --- /dev/null +++ b/tests/baselines/reference/bigintAmbientMinimal.symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/bigintAmbientMinimal.ts] //// + +=== bigintAmbientMinimal.ts === +// Minimal repro from issue +declare const n = 123n; +>n : Symbol(n, Decl(bigintAmbientMinimal.ts, 1, 13)) + +// Non-ambient for comparison +const regular = 456n; +>regular : Symbol(regular, Decl(bigintAmbientMinimal.ts, 4, 5)) + diff --git a/tests/baselines/reference/bigintAmbientMinimal.types b/tests/baselines/reference/bigintAmbientMinimal.types new file mode 100644 index 0000000000000..3ec048a067043 --- /dev/null +++ b/tests/baselines/reference/bigintAmbientMinimal.types @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/bigintAmbientMinimal.ts] //// + +=== bigintAmbientMinimal.ts === +// Minimal repro from issue +declare const n = 123n; +>n : 123n +> : ^^^^ +>123n : 123n +> : ^^^^ + +// Non-ambient for comparison +const regular = 456n; +>regular : 456n +> : ^^^^ +>456n : 456n +> : ^^^^ + From 0e5f1920014207cf6980ab621ae5e4dc401f6867 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:13:53 +0000 Subject: [PATCH 5/8] Address review feedback: fix triple negation in checker.ts and add .d.ts test Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- package-lock.json | 19 +++++++++--------- package.json | 2 +- src/compiler/checker.ts | 3 +-- .../reference/bigintAmbientMinimal.errors.txt | 10 ++++++++-- .../reference/bigintAmbientMinimal.js | 10 ++++++++-- .../reference/bigintAmbientMinimal.symbols | 17 +++++++++++++--- .../reference/bigintAmbientMinimal.types | 20 ++++++++++++++++++- tests/cases/compiler/bigintAmbientMinimal.ts | 7 +++++++ 8 files changed, 68 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index d4d2c055ccfff..bf279bf5481fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "fast-xml-parser": "^4.5.2", "glob": "^10.4.5", "globals": "^15.15.0", - "hereby": "^1.10.0", + "hereby": "^1.11.0", "jsonc-parser": "^3.3.1", "knip": "^5.44.4", "minimist": "^1.2.8", @@ -2878,15 +2878,16 @@ } }, "node_modules/hereby": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.10.0.tgz", - "integrity": "sha512-TyOJ58DFqzCi6PU4/7bDeb2kNIVCPLfJ+RLGdDZxAGIbPRLQ61nupPUtX9QudYHt+dnRpfIHAwclq7SlDc1cDw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", + "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", "dev": true, + "license": "MIT", "dependencies": { "command-line-usage": "^6.1.3", "fastest-levenshtein": "^1.0.16", "minimist": "^1.2.8", - "picocolors": "^1.0.1", + "picocolors": "^1.1.0", "pretty-ms": "^8.0.0" }, "bin": { @@ -6842,15 +6843,15 @@ "dev": true }, "hereby": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.10.0.tgz", - "integrity": "sha512-TyOJ58DFqzCi6PU4/7bDeb2kNIVCPLfJ+RLGdDZxAGIbPRLQ61nupPUtX9QudYHt+dnRpfIHAwclq7SlDc1cDw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", + "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", "dev": true, "requires": { "command-line-usage": "^6.1.3", "fastest-levenshtein": "^1.0.16", "minimist": "^1.2.8", - "picocolors": "^1.0.1", + "picocolors": "^1.1.0", "pretty-ms": "^8.0.0" } }, diff --git a/package.json b/package.json index ef2c80f8b91c2..e7b4c7797d0f8 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "fast-xml-parser": "^4.5.2", "glob": "^10.4.5", "globals": "^15.15.0", - "hereby": "^1.10.0", + "hereby": "^1.11.0", "jsonc-parser": "^3.3.1", "knip": "^5.44.4", "minimist": "^1.2.8", diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80865569d3494..45221e05c6ee7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -53179,8 +53179,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); if (!literalType) { // Don't error on BigInt literals in ambient contexts - const inAmbientContext = !!(node.flags & NodeFlags.Ambient); - if (!inAmbientContext && languageVersion < ScriptTarget.ES2020) { + if (!(node.flags & NodeFlags.Ambient) && languageVersion < ScriptTarget.ES2020) { if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } diff --git a/tests/baselines/reference/bigintAmbientMinimal.errors.txt b/tests/baselines/reference/bigintAmbientMinimal.errors.txt index 827364337eda2..e95b511da01dd 100644 --- a/tests/baselines/reference/bigintAmbientMinimal.errors.txt +++ b/tests/baselines/reference/bigintAmbientMinimal.errors.txt @@ -1,7 +1,13 @@ -bigintAmbientMinimal.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020. +/main.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020. -==== bigintAmbientMinimal.ts (1 errors) ==== +==== /ambient.d.ts (0 errors) ==== + declare const fromDts = 789n; + declare namespace Lib { + const value = 999n; + } + +==== /main.ts (1 errors) ==== // Minimal repro from issue declare const n = 123n; diff --git a/tests/baselines/reference/bigintAmbientMinimal.js b/tests/baselines/reference/bigintAmbientMinimal.js index 2b5a54d27372c..d2147fb7d30fb 100644 --- a/tests/baselines/reference/bigintAmbientMinimal.js +++ b/tests/baselines/reference/bigintAmbientMinimal.js @@ -1,12 +1,18 @@ //// [tests/cases/compiler/bigintAmbientMinimal.ts] //// -//// [bigintAmbientMinimal.ts] +//// [ambient.d.ts] +declare const fromDts = 789n; +declare namespace Lib { + const value = 999n; +} + +//// [main.ts] // Minimal repro from issue declare const n = 123n; // Non-ambient for comparison const regular = 456n; -//// [bigintAmbientMinimal.js] +//// [main.js] // Non-ambient for comparison var regular = 456n; diff --git a/tests/baselines/reference/bigintAmbientMinimal.symbols b/tests/baselines/reference/bigintAmbientMinimal.symbols index 470706aacd00b..d438ba1235958 100644 --- a/tests/baselines/reference/bigintAmbientMinimal.symbols +++ b/tests/baselines/reference/bigintAmbientMinimal.symbols @@ -1,11 +1,22 @@ //// [tests/cases/compiler/bigintAmbientMinimal.ts] //// -=== bigintAmbientMinimal.ts === +=== /ambient.d.ts === +declare const fromDts = 789n; +>fromDts : Symbol(fromDts, Decl(ambient.d.ts, 0, 13)) + +declare namespace Lib { +>Lib : Symbol(Lib, Decl(ambient.d.ts, 0, 29)) + + const value = 999n; +>value : Symbol(value, Decl(ambient.d.ts, 2, 9)) +} + +=== /main.ts === // Minimal repro from issue declare const n = 123n; ->n : Symbol(n, Decl(bigintAmbientMinimal.ts, 1, 13)) +>n : Symbol(n, Decl(main.ts, 1, 13)) // Non-ambient for comparison const regular = 456n; ->regular : Symbol(regular, Decl(bigintAmbientMinimal.ts, 4, 5)) +>regular : Symbol(regular, Decl(main.ts, 4, 5)) diff --git a/tests/baselines/reference/bigintAmbientMinimal.types b/tests/baselines/reference/bigintAmbientMinimal.types index 3ec048a067043..086ac1d5676be 100644 --- a/tests/baselines/reference/bigintAmbientMinimal.types +++ b/tests/baselines/reference/bigintAmbientMinimal.types @@ -1,6 +1,24 @@ //// [tests/cases/compiler/bigintAmbientMinimal.ts] //// -=== bigintAmbientMinimal.ts === +=== /ambient.d.ts === +declare const fromDts = 789n; +>fromDts : 789n +> : ^^^^ +>789n : 789n +> : ^^^^ + +declare namespace Lib { +>Lib : typeof Lib +> : ^^^^^^^^^^ + + const value = 999n; +>value : 999n +> : ^^^^ +>999n : 999n +> : ^^^^ +} + +=== /main.ts === // Minimal repro from issue declare const n = 123n; >n : 123n diff --git a/tests/cases/compiler/bigintAmbientMinimal.ts b/tests/cases/compiler/bigintAmbientMinimal.ts index 144cd6a74d87a..4bad00279bcfd 100644 --- a/tests/cases/compiler/bigintAmbientMinimal.ts +++ b/tests/cases/compiler/bigintAmbientMinimal.ts @@ -1,5 +1,12 @@ // @target: ES5 +// @Filename: /ambient.d.ts +declare const fromDts = 789n; +declare namespace Lib { + const value = 999n; +} + +// @Filename: /main.ts // Minimal repro from issue declare const n = 123n; From b630c89c2223081966c6348b23b775330df7a24d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:18:02 +0000 Subject: [PATCH 6/8] Revert unintentional package.json and package-lock.json changes Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- package-lock.json | 19 +++++++++---------- package.json | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index bf279bf5481fa..d4d2c055ccfff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "fast-xml-parser": "^4.5.2", "glob": "^10.4.5", "globals": "^15.15.0", - "hereby": "^1.11.0", + "hereby": "^1.10.0", "jsonc-parser": "^3.3.1", "knip": "^5.44.4", "minimist": "^1.2.8", @@ -2878,16 +2878,15 @@ } }, "node_modules/hereby": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", - "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.10.0.tgz", + "integrity": "sha512-TyOJ58DFqzCi6PU4/7bDeb2kNIVCPLfJ+RLGdDZxAGIbPRLQ61nupPUtX9QudYHt+dnRpfIHAwclq7SlDc1cDw==", "dev": true, - "license": "MIT", "dependencies": { "command-line-usage": "^6.1.3", "fastest-levenshtein": "^1.0.16", "minimist": "^1.2.8", - "picocolors": "^1.1.0", + "picocolors": "^1.0.1", "pretty-ms": "^8.0.0" }, "bin": { @@ -6843,15 +6842,15 @@ "dev": true }, "hereby": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.11.0.tgz", - "integrity": "sha512-Tdp03ueQL3w5eZCrQVW4POBDxg9ldjNyFrZYWt6ndMha5agyRUO8b+irOEG3B1RSS9/2LxSjjyG6DSxITouJzA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/hereby/-/hereby-1.10.0.tgz", + "integrity": "sha512-TyOJ58DFqzCi6PU4/7bDeb2kNIVCPLfJ+RLGdDZxAGIbPRLQ61nupPUtX9QudYHt+dnRpfIHAwclq7SlDc1cDw==", "dev": true, "requires": { "command-line-usage": "^6.1.3", "fastest-levenshtein": "^1.0.16", "minimist": "^1.2.8", - "picocolors": "^1.1.0", + "picocolors": "^1.0.1", "pretty-ms": "^8.0.0" } }, diff --git a/package.json b/package.json index e7b4c7797d0f8..ef2c80f8b91c2 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "fast-xml-parser": "^4.5.2", "glob": "^10.4.5", "globals": "^15.15.0", - "hereby": "^1.11.0", + "hereby": "^1.10.0", "jsonc-parser": "^3.3.1", "knip": "^5.44.4", "minimist": "^1.2.8", From 319630cad17edcab535ac7c8138fdfc3280dab6f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:40:35 +0000 Subject: [PATCH 7/8] Fix line endings in checker.ts to use CRLF consistently Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- src/compiler/checker.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 45221e05c6ee7..68e29083b7fa0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -53177,15 +53177,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean { const literalType = isLiteralTypeNode(node.parent) || isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); - if (!literalType) { - // Don't error on BigInt literals in ambient contexts - if (!(node.flags & NodeFlags.Ambient) && languageVersion < ScriptTarget.ES2020) { - if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { - return true; - } - } - } - return false; + if (!literalType) { + // Don't error on BigInt literals in ambient contexts + if (!(node.flags & NodeFlags.Ambient) && languageVersion < ScriptTarget.ES2020) { + if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { + return true; + } + } + } + return false; } function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, ...args: DiagnosticArguments): boolean { From 3163a69a7e1eabf94bd8bd3767d134abf6c11f8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:54:46 +0000 Subject: [PATCH 8/8] Fix line endings in checker.ts to consistently use CRLF Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 68e29083b7fa0..50d7f4785be4e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -53174,9 +53174,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addErrorOrSuggestion(/*isError*/ false, createDiagnosticForNode(node, Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); } - function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean { - const literalType = isLiteralTypeNode(node.parent) || - isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); + function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean { + const literalType = isLiteralTypeNode(node.parent) || + isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent); if (!literalType) { // Don't error on BigInt literals in ambient contexts if (!(node.flags & NodeFlags.Ambient) && languageVersion < ScriptTarget.ES2020) {