Skip to content

Commit 0e5f192

Browse files
Address review feedback: fix triple negation in checker.ts and add .d.ts test
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
1 parent bed7418 commit 0e5f192

File tree

8 files changed

+68
-20
lines changed

8 files changed

+68
-20
lines changed

package-lock.json

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"fast-xml-parser": "^4.5.2",
6969
"glob": "^10.4.5",
7070
"globals": "^15.15.0",
71-
"hereby": "^1.10.0",
71+
"hereby": "^1.11.0",
7272
"jsonc-parser": "^3.3.1",
7373
"knip": "^5.44.4",
7474
"minimist": "^1.2.8",

src/compiler/checker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53179,8 +53179,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5317953179
isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent);
5318053180
if (!literalType) {
5318153181
// Don't error on BigInt literals in ambient contexts
53182-
const inAmbientContext = !!(node.flags & NodeFlags.Ambient);
53183-
if (!inAmbientContext && languageVersion < ScriptTarget.ES2020) {
53182+
if (!(node.flags & NodeFlags.Ambient) && languageVersion < ScriptTarget.ES2020) {
5318453183
if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
5318553184
return true;
5318653185
}

tests/baselines/reference/bigintAmbientMinimal.errors.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
bigintAmbientMinimal.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020.
1+
/main.ts(5,17): error TS2737: BigInt literals are not available when targeting lower than ES2020.
22

33

4-
==== bigintAmbientMinimal.ts (1 errors) ====
4+
==== /ambient.d.ts (0 errors) ====
5+
declare const fromDts = 789n;
6+
declare namespace Lib {
7+
const value = 999n;
8+
}
9+
10+
==== /main.ts (1 errors) ====
511
// Minimal repro from issue
612
declare const n = 123n;
713

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
//// [tests/cases/compiler/bigintAmbientMinimal.ts] ////
22

3-
//// [bigintAmbientMinimal.ts]
3+
//// [ambient.d.ts]
4+
declare const fromDts = 789n;
5+
declare namespace Lib {
6+
const value = 999n;
7+
}
8+
9+
//// [main.ts]
410
// Minimal repro from issue
511
declare const n = 123n;
612

713
// Non-ambient for comparison
814
const regular = 456n;
915

10-
//// [bigintAmbientMinimal.js]
16+
//// [main.js]
1117
// Non-ambient for comparison
1218
var regular = 456n;
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
//// [tests/cases/compiler/bigintAmbientMinimal.ts] ////
22

3-
=== bigintAmbientMinimal.ts ===
3+
=== /ambient.d.ts ===
4+
declare const fromDts = 789n;
5+
>fromDts : Symbol(fromDts, Decl(ambient.d.ts, 0, 13))
6+
7+
declare namespace Lib {
8+
>Lib : Symbol(Lib, Decl(ambient.d.ts, 0, 29))
9+
10+
const value = 999n;
11+
>value : Symbol(value, Decl(ambient.d.ts, 2, 9))
12+
}
13+
14+
=== /main.ts ===
415
// Minimal repro from issue
516
declare const n = 123n;
6-
>n : Symbol(n, Decl(bigintAmbientMinimal.ts, 1, 13))
17+
>n : Symbol(n, Decl(main.ts, 1, 13))
718

819
// Non-ambient for comparison
920
const regular = 456n;
10-
>regular : Symbol(regular, Decl(bigintAmbientMinimal.ts, 4, 5))
21+
>regular : Symbol(regular, Decl(main.ts, 4, 5))
1122

tests/baselines/reference/bigintAmbientMinimal.types

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
//// [tests/cases/compiler/bigintAmbientMinimal.ts] ////
22

3-
=== bigintAmbientMinimal.ts ===
3+
=== /ambient.d.ts ===
4+
declare const fromDts = 789n;
5+
>fromDts : 789n
6+
> : ^^^^
7+
>789n : 789n
8+
> : ^^^^
9+
10+
declare namespace Lib {
11+
>Lib : typeof Lib
12+
> : ^^^^^^^^^^
13+
14+
const value = 999n;
15+
>value : 999n
16+
> : ^^^^
17+
>999n : 999n
18+
> : ^^^^
19+
}
20+
21+
=== /main.ts ===
422
// Minimal repro from issue
523
declare const n = 123n;
624
>n : 123n

tests/cases/compiler/bigintAmbientMinimal.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// @target: ES5
22

3+
// @Filename: /ambient.d.ts
4+
declare const fromDts = 789n;
5+
declare namespace Lib {
6+
const value = 999n;
7+
}
8+
9+
// @Filename: /main.ts
310
// Minimal repro from issue
411
declare const n = 123n;
512

0 commit comments

Comments
 (0)