File tree Expand file tree Collapse file tree 3 files changed +4
-41
lines changed
testdata/baselines/reference/submodule/compiler Expand file tree Collapse file tree 3 files changed +4
-41
lines changed Original file line number Diff line number Diff line change @@ -2145,7 +2145,8 @@ func (c *Checker) checkGrammarNumericLiteral(node *ast.NumericLiteral) {
21452145func (c * Checker ) checkGrammarBigIntLiteral (node * ast.BigIntLiteral ) bool {
21462146 literalType := ast .IsLiteralTypeNode (node .Parent ) || ast .IsPrefixUnaryExpression (node .Parent ) && ast .IsLiteralTypeNode (node .Parent .Parent )
21472147 if ! literalType {
2148- if c .languageVersion < core .ScriptTargetES2020 {
2148+ // Don't error on BigInt literals in ambient contexts
2149+ if node .Flags & ast .NodeFlagsAmbient == 0 && c .languageVersion < core .ScriptTargetES2020 {
21492150 if c .grammarErrorOnNode (node .AsNode (), diagnostics .BigInt_literals_are_not_available_when_targeting_lower_than_ES2020 ) {
21502151 return true
21512152 }
Original file line number Diff line number Diff line change 1- /ambient.d.ts(1,25): error TS2737: BigInt literals are not available when targeting lower than ES2020.
2- /ambient.d.ts(3,19): error TS2737: BigInt literals are not available when targeting lower than ES2020.
3- /main.ts(2,19): error TS2737: BigInt literals are not available when targeting lower than ES2020.
41/main.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020.
52
63
7- ==== /ambient.d.ts (2 errors) ====
4+ ==== /ambient.d.ts (0 errors) ====
85 declare const fromDts = 789n;
9- ~~~~
10- !!! error TS2737: BigInt literals are not available when targeting lower than ES2020.
116 declare namespace Lib {
127 const value = 999n;
13- ~~~~
14- !!! error TS2737: BigInt literals are not available when targeting lower than ES2020.
158 }
169
17- ==== /main.ts (2 errors) ====
10+ ==== /main.ts (1 errors) ====
1811 // Minimal repro from issue
1912 declare const n = 123n;
20- ~~~~
21- !!! error TS2737: BigInt literals are not available when targeting lower than ES2020.
2213
2314 // Non-ambient for comparison
2415 const regular = 456n;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments