-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix BigInt literal error in ambient contexts when targeting < ES2020 #61935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a848b40
Initial plan for issue
Copilot aad8e0d
Add test case demonstrating BigInt literal error in ambient contexts
Copilot abdc70a
Fix BigInt literal error in ambient contexts
Copilot bed7418
Add test baselines for BigInt literals in ambient contexts
Copilot 0e5f192
Address review feedback: fix triple negation in checker.ts and add .d…
Copilot b630c89
Revert unintentional package.json and package-lock.json changes
Copilot 319630c
Fix line endings in checker.ts to use CRLF consistently
Copilot 3163a69
Fix line endings in checker.ts to consistently use CRLF
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/main.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020. | ||
|
||
|
||
==== /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; | ||
|
||
// Non-ambient for comparison | ||
const regular = 456n; | ||
~~~~ | ||
!!! error TS2737: BigInt literals are not available when targeting lower than ES2020. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//// [tests/cases/compiler/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; | ||
|
||
//// [main.js] | ||
// Non-ambient for comparison | ||
var regular = 456n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//// [tests/cases/compiler/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(main.ts, 1, 13)) | ||
|
||
// Non-ambient for comparison | ||
const regular = 456n; | ||
>regular : Symbol(regular, Decl(main.ts, 4, 5)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//// [tests/cases/compiler/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 | ||
> : ^^^^ | ||
>123n : 123n | ||
> : ^^^^ | ||
|
||
// Non-ambient for comparison | ||
const regular = 456n; | ||
>regular : 456n | ||
> : ^^^^ | ||
>456n : 456n | ||
> : ^^^^ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @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; | ||
|
||
// Non-ambient for comparison | ||
const regular = 456n; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use triple negation, just inline the flag check here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by removing the intermediate variable and inlining the flag check. Commit 0e5f192.