mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-23 10:04:47 -05:00
Bigint constructor forbids object null undefined (#43204)
* Update es2020.bigint.d.ts * Update es2020.bigint.d.ts * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * add a test Co-authored-by: 龙腾道 <LongTengDao@LongTengDao.com> Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
e44d39d4eb
commit
2ea2f4f9a0
2
src/lib/es2020.bigint.d.ts
vendored
2
src/lib/es2020.bigint.d.ts
vendored
@@ -101,7 +101,7 @@ interface BigInt {
|
||||
}
|
||||
|
||||
interface BigIntConstructor {
|
||||
(value?: any): bigint;
|
||||
(value: bigint | boolean | number | string): bigint;
|
||||
readonly prototype: BigInt;
|
||||
|
||||
/**
|
||||
|
||||
28
tests/baselines/reference/constructBigint.errors.txt
Normal file
28
tests/baselines/reference/constructBigint.errors.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
tests/cases/conformance/es2020/constructBigint.ts(6,8): error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
tests/cases/conformance/es2020/constructBigint.ts(7,8): error TS2345: Argument of type '{ e: number; m: number; }' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
Type '{ e: number; m: number; }' is not assignable to type 'true'.
|
||||
tests/cases/conformance/es2020/constructBigint.ts(8,8): error TS2345: Argument of type 'null' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
tests/cases/conformance/es2020/constructBigint.ts(9,8): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es2020/constructBigint.ts (4 errors) ====
|
||||
BigInt(1);
|
||||
BigInt(1n);
|
||||
BigInt("0");
|
||||
BigInt(false);
|
||||
|
||||
BigInt(Symbol());
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'symbol' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
BigInt({ e: 1, m: 1 })
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ e: number; m: number; }' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
!!! error TS2345: Type '{ e: number; m: number; }' is not assignable to type 'true'.
|
||||
BigInt(null);
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'null' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
BigInt(undefined)
|
||||
~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'string | number | bigint | boolean'.
|
||||
|
||||
|
||||
23
tests/baselines/reference/constructBigint.js
Normal file
23
tests/baselines/reference/constructBigint.js
Normal file
@@ -0,0 +1,23 @@
|
||||
//// [constructBigint.ts]
|
||||
BigInt(1);
|
||||
BigInt(1n);
|
||||
BigInt("0");
|
||||
BigInt(false);
|
||||
|
||||
BigInt(Symbol());
|
||||
BigInt({ e: 1, m: 1 })
|
||||
BigInt(null);
|
||||
BigInt(undefined)
|
||||
|
||||
|
||||
|
||||
//// [constructBigint.js]
|
||||
"use strict";
|
||||
BigInt(1);
|
||||
BigInt(1n);
|
||||
BigInt("0");
|
||||
BigInt(false);
|
||||
BigInt(Symbol());
|
||||
BigInt({ e: 1, m: 1 });
|
||||
BigInt(null);
|
||||
BigInt(undefined);
|
||||
30
tests/baselines/reference/constructBigint.symbols
Normal file
30
tests/baselines/reference/constructBigint.symbols
Normal file
@@ -0,0 +1,30 @@
|
||||
=== tests/cases/conformance/es2020/constructBigint.ts ===
|
||||
BigInt(1);
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
BigInt(1n);
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
BigInt("0");
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
BigInt(false);
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
BigInt(Symbol());
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --))
|
||||
|
||||
BigInt({ e: 1, m: 1 })
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(constructBigint.ts, 6, 8))
|
||||
>m : Symbol(m, Decl(constructBigint.ts, 6, 14))
|
||||
|
||||
BigInt(null);
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
|
||||
BigInt(undefined)
|
||||
>BigInt : Symbol(BigInt, Decl(lib.es2020.bigint.d.ts, --, --), Decl(lib.es2020.bigint.d.ts, --, --))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
|
||||
47
tests/baselines/reference/constructBigint.types
Normal file
47
tests/baselines/reference/constructBigint.types
Normal file
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/conformance/es2020/constructBigint.ts ===
|
||||
BigInt(1);
|
||||
>BigInt(1) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>1 : 1
|
||||
|
||||
BigInt(1n);
|
||||
>BigInt(1n) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>1n : 1n
|
||||
|
||||
BigInt("0");
|
||||
>BigInt("0") : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>"0" : "0"
|
||||
|
||||
BigInt(false);
|
||||
>BigInt(false) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>false : false
|
||||
|
||||
BigInt(Symbol());
|
||||
>BigInt(Symbol()) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
BigInt({ e: 1, m: 1 })
|
||||
>BigInt({ e: 1, m: 1 }) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>{ e: 1, m: 1 } : { e: number; m: number; }
|
||||
>e : number
|
||||
>1 : 1
|
||||
>m : number
|
||||
>1 : 1
|
||||
|
||||
BigInt(null);
|
||||
>BigInt(null) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>null : null
|
||||
|
||||
BigInt(undefined)
|
||||
>BigInt(undefined) : bigint
|
||||
>BigInt : BigIntConstructor
|
||||
>undefined : undefined
|
||||
|
||||
|
||||
13
tests/cases/conformance/es2020/constructBigint.ts
Normal file
13
tests/cases/conformance/es2020/constructBigint.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @strict: true
|
||||
BigInt(1);
|
||||
BigInt(1n);
|
||||
BigInt("0");
|
||||
BigInt(false);
|
||||
|
||||
BigInt(Symbol());
|
||||
BigInt({ e: 1, m: 1 })
|
||||
BigInt(null);
|
||||
BigInt(undefined)
|
||||
|
||||
Reference in New Issue
Block a user