Skip to content

Error on missing BigInt in es2020 #37899

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 2 commits into from
Apr 13, 2020
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
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10349,7 +10349,7 @@ namespace ts {
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(<IntersectionType>t) :
t.flags & TypeFlags.StringLike ? globalStringType :
t.flags & TypeFlags.NumberLike ? globalNumberType :
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ESNext) :
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) :
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) :
t.flags & TypeFlags.NonPrimitive ? emptyObjectType :
Expand Down
13 changes: 13 additions & 0 deletions tests/baselines/reference/bigintMissingES2019.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [bigintMissingES2019.ts]
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// no error when bigint is used even when ES2020 lib is not present


//// [bigintMissingES2019.js]
test();
test();
// no error when bigint is used even when ES2020 lib is not present
17 changes: 17 additions & 0 deletions tests/baselines/reference/bigintMissingES2019.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/conformance/es2020/bigintMissingES2019.ts ===
declare function test<A, B extends A>(): void;
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22))
>B : Symbol(B, Decl(bigintMissingES2019.ts, 0, 24))
>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22))

test<{t?: string}, object>();
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingES2019.ts, 2, 6))

test<{t?: string}, bigint>();
>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingES2019.ts, 3, 6))

// no error when bigint is used even when ES2020 lib is not present

16 changes: 16 additions & 0 deletions tests/baselines/reference/bigintMissingES2019.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/es2020/bigintMissingES2019.ts ===
declare function test<A, B extends A>(): void;
>test : <A, B extends A>() => void

test<{t?: string}, object>();
>test<{t?: string}, object>() : void
>test : <A, B extends A>() => void
>t : string

test<{t?: string}, bigint>();
>test<{t?: string}, bigint>() : void
>test : <A, B extends A>() => void
>t : string

// no error when bigint is used even when ES2020 lib is not present

12 changes: 12 additions & 0 deletions tests/baselines/reference/bigintMissingES2020.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error TS2318: Cannot find global type 'BigInt'.


!!! error TS2318: Cannot find global type 'BigInt'.
==== tests/cases/conformance/es2020/bigintMissingES2020.ts (0 errors) ====
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present

13 changes: 13 additions & 0 deletions tests/baselines/reference/bigintMissingES2020.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [bigintMissingES2020.ts]
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present


//// [bigintMissingES2020.js]
test();
test();
// should have global error when bigint is used but ES2020 lib is not present
17 changes: 17 additions & 0 deletions tests/baselines/reference/bigintMissingES2020.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/conformance/es2020/bigintMissingES2020.ts ===
declare function test<A, B extends A>(): void;
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22))
>B : Symbol(B, Decl(bigintMissingES2020.ts, 0, 24))
>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22))

test<{t?: string}, object>();
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingES2020.ts, 2, 6))

test<{t?: string}, bigint>();
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingES2020.ts, 3, 6))

// should have global error when bigint is used but ES2020 lib is not present

16 changes: 16 additions & 0 deletions tests/baselines/reference/bigintMissingES2020.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/es2020/bigintMissingES2020.ts ===
declare function test<A, B extends A>(): void;
>test : <A, B extends A>() => void

test<{t?: string}, object>();
>test<{t?: string}, object>() : void
>test : <A, B extends A>() => void
>t : string

test<{t?: string}, bigint>();
>test<{t?: string}, bigint>() : void
>test : <A, B extends A>() => void
>t : string

// should have global error when bigint is used but ES2020 lib is not present

12 changes: 12 additions & 0 deletions tests/baselines/reference/bigintMissingESNext.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error TS2318: Cannot find global type 'BigInt'.


!!! error TS2318: Cannot find global type 'BigInt'.
==== tests/cases/conformance/es2020/bigintMissingESNext.ts (0 errors) ====
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present

13 changes: 13 additions & 0 deletions tests/baselines/reference/bigintMissingESNext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [bigintMissingESNext.ts]
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present


//// [bigintMissingESNext.js]
test();
test();
// should have global error when bigint is used but ES2020 lib is not present
17 changes: 17 additions & 0 deletions tests/baselines/reference/bigintMissingESNext.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/conformance/es2020/bigintMissingESNext.ts ===
declare function test<A, B extends A>(): void;
>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0))
>A : Symbol(A, Decl(bigintMissingESNext.ts, 0, 22))
>B : Symbol(B, Decl(bigintMissingESNext.ts, 0, 24))
>A : Symbol(A, Decl(bigintMissingESNext.ts, 0, 22))

test<{t?: string}, object>();
>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingESNext.ts, 2, 6))

test<{t?: string}, bigint>();
>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0))
>t : Symbol(t, Decl(bigintMissingESNext.ts, 3, 6))

// should have global error when bigint is used but ES2020 lib is not present

16 changes: 16 additions & 0 deletions tests/baselines/reference/bigintMissingESNext.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/es2020/bigintMissingESNext.ts ===
declare function test<A, B extends A>(): void;
>test : <A, B extends A>() => void

test<{t?: string}, object>();
>test<{t?: string}, object>() : void
>test : <A, B extends A>() => void
>t : string

test<{t?: string}, bigint>();
>test<{t?: string}, bigint>() : void
>test : <A, B extends A>() => void
>t : string

// should have global error when bigint is used but ES2020 lib is not present

8 changes: 8 additions & 0 deletions tests/cases/conformance/es2020/bigintMissingES2019.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @target: es2019
// @lib: dom,es2019
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// no error when bigint is used even when ES2020 lib is not present
8 changes: 8 additions & 0 deletions tests/cases/conformance/es2020/bigintMissingES2020.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @target: es2020
// @lib: dom,es2017
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present
8 changes: 8 additions & 0 deletions tests/cases/conformance/es2020/bigintMissingESNext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @target: esnext
// @lib: dom,es2017
declare function test<A, B extends A>(): void;

test<{t?: string}, object>();
test<{t?: string}, bigint>();

// should have global error when bigint is used but ES2020 lib is not present