Skip to content

error TS2318: Cannot find global type 'BigInt' #49101

Closed
@h-joo

Description

@h-joo

Bug Report

The provided code fails with compiler error: error TS2318: Cannot find global type 'BigInt'. without any location information.

🔎 Search Terms

BigInt, Object.freeze

🕗 Version & Regression Information

This changed between versions 4.6.4 and 4.7-beta

⏯ Playground Link

No playground reproduce for this bug as it's not possible to set target and lib differently from the playground.

Steps to reproduce

mkdir test_47rc
cd test_47rc
npm init
npm install typescript@rc
echo "Object.freeze({foo() {}});" > index.ts
./node_modules/.bin/tsc --target es2020 --lib es2019 index.ts

Note : ./node_modules/.bin/tsc --target es2020 --lib es2020 index.ts does not print an error.

💻 Code

Object.freeze({foo() {}});

🙁 Actual behavior

TypeScript compiler prints error TS2318: Cannot find global type 'BigInt'. without any source location.

🙂 Expected behavior

I'm not sure what the actual behavior here needs to be, but at least the new additioal type definition of Object.freeze in lib.es5.d.ts start to trigger this failure.

    /**
     * Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
     * @param o Object on which to lock the attributes.
     */
    freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;

I think the lib.es5.d.ts should not contain type definition that uses bigint

Please let me know if this should go to https://github.com/microsoft/TypeScript-DOM-lib-generator/issues instead.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions