Fix BigInt literal error in ambient contexts when targeting < ES2020 (#61935)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
This commit is contained in:
Copilot
2025-06-25 14:29:50 -07:00
committed by GitHub
co-authored by RyanCavanaugh
parent 1ed8674bba
commit 6e519c59c1
6 changed files with 108 additions and 1 deletions
+2 -1
View File
@@ -53188,7 +53188,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const literalType = isLiteralTypeNode(node.parent) ||
isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent);
if (!literalType) {
if (languageVersion < ScriptTarget.ES2020) {
// 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;
}