diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index 15c92f072fc..31844087eb4 100644 --- a/src/lib/es2020.bigint.d.ts +++ b/src/lib/es2020.bigint.d.ts @@ -101,7 +101,7 @@ interface BigInt { } interface BigIntConstructor { - (value?: any): bigint; + (value: bigint | boolean | number | string): bigint; readonly prototype: BigInt; /** diff --git a/tests/baselines/reference/constructBigint.errors.txt b/tests/baselines/reference/constructBigint.errors.txt new file mode 100644 index 00000000000..c9aab7d655e --- /dev/null +++ b/tests/baselines/reference/constructBigint.errors.txt @@ -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'. + + \ No newline at end of file diff --git a/tests/baselines/reference/constructBigint.js b/tests/baselines/reference/constructBigint.js new file mode 100644 index 00000000000..3965176045f --- /dev/null +++ b/tests/baselines/reference/constructBigint.js @@ -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); diff --git a/tests/baselines/reference/constructBigint.symbols b/tests/baselines/reference/constructBigint.symbols new file mode 100644 index 00000000000..89c36919809 --- /dev/null +++ b/tests/baselines/reference/constructBigint.symbols @@ -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) + + diff --git a/tests/baselines/reference/constructBigint.types b/tests/baselines/reference/constructBigint.types new file mode 100644 index 00000000000..ac85ccaccb7 --- /dev/null +++ b/tests/baselines/reference/constructBigint.types @@ -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 + + diff --git a/tests/cases/conformance/es2020/constructBigint.ts b/tests/cases/conformance/es2020/constructBigint.ts new file mode 100644 index 00000000000..4ac6a159a73 --- /dev/null +++ b/tests/cases/conformance/es2020/constructBigint.ts @@ -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) +