Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5f46d42

Browse filesBrowse files
authored
Error on missing BigInt in es2020 (microsoft#37899)
* Error on missing BigInt in ES2020 too. Previously it was only on ESNext, but bigint ships in ES 2020. There are no tests for this; passing `false` doesn't cause any tests to fail at least. * add tests
1 parent eb105ef commit 5f46d42
Copy full SHA for 5f46d42

15 files changed

+187-1Lines changed: 187 additions & 1 deletion
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10358,7 +10358,7 @@ namespace ts {
1035810358
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(<IntersectionType>t) :
1035910359
t.flags & TypeFlags.StringLike ? globalStringType :
1036010360
t.flags & TypeFlags.NumberLike ? globalNumberType :
10361-
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ESNext) :
10361+
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) :
1036210362
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
1036310363
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) :
1036410364
t.flags & TypeFlags.NonPrimitive ? emptyObjectType :
Collapse file
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [bigintMissingES2019.ts]
2+
declare function test<A, B extends A>(): void;
3+
4+
test<{t?: string}, object>();
5+
test<{t?: string}, bigint>();
6+
7+
// no error when bigint is used even when ES2020 lib is not present
8+
9+
10+
//// [bigintMissingES2019.js]
11+
test();
12+
test();
13+
// no error when bigint is used even when ES2020 lib is not present
Collapse file
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/es2020/bigintMissingES2019.ts ===
2+
declare function test<A, B extends A>(): void;
3+
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
4+
>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22))
5+
>B : Symbol(B, Decl(bigintMissingES2019.ts, 0, 24))
6+
>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22))
7+
8+
test<{t?: string}, object>();
9+
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
10+
>t : Symbol(t, Decl(bigintMissingES2019.ts, 2, 6))
11+
12+
test<{t?: string}, bigint>();
13+
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
14+
>t : Symbol(t, Decl(bigintMissingES2019.ts, 3, 6))
15+
16+
// no error when bigint is used even when ES2020 lib is not present
17+
Collapse file
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/es2020/bigintMissingES2019.ts ===
2+
declare function test<A, B extends A>(): void;
3+
>test : <A, B extends A>() => void
4+
5+
test<{t?: string}, object>();
6+
>test<{t?: string}, object>() : void
7+
>test : <A, B extends A>() => void
8+
>t : string
9+
10+
test<{t?: string}, bigint>();
11+
>test<{t?: string}, bigint>() : void
12+
>test : <A, B extends A>() => void
13+
>t : string
14+
15+
// no error when bigint is used even when ES2020 lib is not present
16+
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error TS2318: Cannot find global type 'BigInt'.
2+
3+
4+
!!! error TS2318: Cannot find global type 'BigInt'.
5+
==== tests/cases/conformance/es2020/bigintMissingES2020.ts (0 errors) ====
6+
declare function test<A, B extends A>(): void;
7+
8+
test<{t?: string}, object>();
9+
test<{t?: string}, bigint>();
10+
11+
// should have global error when bigint is used but ES2020 lib is not present
12+
Collapse file
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [bigintMissingES2020.ts]
2+
declare function test<A, B extends A>(): void;
3+
4+
test<{t?: string}, object>();
5+
test<{t?: string}, bigint>();
6+
7+
// should have global error when bigint is used but ES2020 lib is not present
8+
9+
10+
//// [bigintMissingES2020.js]
11+
test();
12+
test();
13+
// should have global error when bigint is used but ES2020 lib is not present
Collapse file
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/conformance/es2020/bigintMissingES2020.ts ===
2+
declare function test<A, B extends A>(): void;
3+
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
4+
>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22))
5+
>B : Symbol(B, Decl(bigintMissingES2020.ts, 0, 24))
6+
>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22))
7+
8+
test<{t?: string}, object>();
9+
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
10+
>t : Symbol(t, Decl(bigintMissingES2020.ts, 2, 6))
11+
12+
test<{t?: string}, bigint>();
13+
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
14+
>t : Symbol(t, Decl(bigintMissingES2020.ts, 3, 6))
15+
16+
// should have global error when bigint is used but ES2020 lib is not present
17+
Collapse file
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/es2020/bigintMissingES2020.ts ===
2+
declare function test<A, B extends A>(): void;
3+
>test : <A, B extends A>() => void
4+
5+
test<{t?: string}, object>();
6+
>test<{t?: string}, object>() : void
7+
>test : <A, B extends A>() => void
8+
>t : string
9+
10+
test<{t?: string}, bigint>();
11+
>test<{t?: string}, bigint>() : void
12+
>test : <A, B extends A>() => void
13+
>t : string
14+
15+
// should have global error when bigint is used but ES2020 lib is not present
16+
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error TS2318: Cannot find global type 'BigInt'.
2+
3+
4+
!!! error TS2318: Cannot find global type 'BigInt'.
5+
==== tests/cases/conformance/es2020/bigintMissingESNext.ts (0 errors) ====
6+
declare function test<A, B extends A>(): void;
7+
8+
test<{t?: string}, object>();
9+
test<{t?: string}, bigint>();
10+
11+
// should have global error when bigint is used but ES2020 lib is not present
12+
Collapse file
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [bigintMissingESNext.ts]
2+
declare function test<A, B extends A>(): void;
3+
4+
test<{t?: string}, object>();
5+
test<{t?: string}, bigint>();
6+
7+
// should have global error when bigint is used but ES2020 lib is not present
8+
9+
10+
//// [bigintMissingESNext.js]
11+
test();
12+
test();
13+
// should have global error when bigint is used but ES2020 lib is not present

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.