TS2583

error TS2583: Cannot find name ‘BigInt’. Do you need to change your target library? Try changing the ‘lib’ compiler option to ‘es2020’ or later.

Broken Code ❌

tsconfig.json
1
2
3
4
5
6
7
{
"compilerOptions": {
"lib": [
"dom"
]
}
}
ImmortalPerson.ts
1
2
3
type ImmortalPerson = {
age: BigInt;
}

Fixed Code ✔️

Arbitrary-precision integers (BigInt) were introduced in 11th edition of the ECMAScript Language Specification (ES11 / ES2020), so you have to add this information to the “lib” property of your TypeScript configuration to make use of this API:

tsconfig.json
1
2
3
4
5
6
7
8
{
"compilerOptions": {
"lib": [
"dom",
"es2020.bigint"
]
}
}

Alternatively, you can make all additional APIs from ES2020 available to your code:

tsconfig.json
1
2
3
4
5
6
7
8
{
"compilerOptions": {
"lib": [
"dom",
"es2020"
]
}
}