Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,8 @@ func (c *Checker) checkGrammarNumericLiteral(node *ast.NumericLiteral) {
func (c *Checker) checkGrammarBigIntLiteral(node *ast.BigIntLiteral) bool {
literalType := ast.IsLiteralTypeNode(node.Parent) || ast.IsPrefixUnaryExpression(node.Parent) && ast.IsLiteralTypeNode(node.Parent.Parent)
if !literalType {
if c.languageVersion < core.ScriptTargetES2020 {
// Don't error on BigInt literals in ambient contexts
if node.Flags&ast.NodeFlagsAmbient == 0 && c.languageVersion < core.ScriptTargetES2020 {
if c.grammarErrorOnNode(node.AsNode(), diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020) {
return true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
/ambient.d.ts(1,25): error TS2737: BigInt literals are not available when targeting lower than ES2020.
/ambient.d.ts(3,19): error TS2737: BigInt literals are not available when targeting lower than ES2020.
/main.ts(2,19): 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.


==== /ambient.d.ts (2 errors) ====
==== /ambient.d.ts (0 errors) ====
declare const fromDts = 789n;
~~~~
!!! error TS2737: BigInt literals are not available when targeting lower than ES2020.
declare namespace Lib {
const value = 999n;
~~~~
!!! error TS2737: BigInt literals are not available when targeting lower than ES2020.
}

==== /main.ts (2 errors) ====
==== /main.ts (1 errors) ====
// Minimal repro from issue
declare const n = 123n;
~~~~
!!! error TS2737: BigInt literals are not available when targeting lower than ES2020.

// Non-ambient for comparison
const regular = 456n;
Expand Down

This file was deleted.