You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
error TS2318: Cannot find global type 'BigInt' #49101
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
I think the lib.es5.d.ts should not contain type definition that uses bigint
That's a necessary evil afaik because all the later targets reference lib.es5.d.ts and the function definition can't be modified once it's been declared.
I think there's an error when the target is less than es2020 too, but errors resolving BigInt are suppressed when target is less than es2020.
This happens in getContextualSignature, which only runs on object literal methods. So it's an error for { f() { } } and { f: function () { } } but not for { f: () => { } }.
The current behaviour for BigInt is to fall back to {} when interface BigInt is not declared globally. Additionally, issue an error when target >= es2020.
Some better fixes:
Issue a new error when the lib is older than the target. (newer? different?).
Issue this error when target >= es2020 AND target === lib.
Issue this error when target >= es2020 AND lib >= es2020.
Issue this error when lib >= es2020.
(1) is probably separate from (2-4). I don't know what should be allowed here -- for example, as long as the emit for es2020 doesn't rely on es2015 stdlib declarations, it should be fine to have target=es2020 and lib=es5.
Activity
fatcerberus commentedon May 13, 2022
That's a necessary evil afaik because all the later targets reference
lib.es5.d.tsand the function definition can't be modified once it's been declared.DanielRosenwasser commentedon May 13, 2022
Ryan Cavanaugh (@RyanCavanaugh) 4.7.1, 4.7.2, or 4.8.0?
RyanCavanaugh commentedon May 13, 2022
4.7.2
sandersn commentedon May 13, 2022
I think there's an error when the target is less than es2020 too, but errors resolving
BigIntare suppressed when target is less than es2020.This happens in
getContextualSignature, which only runs on object literal methods. So it's an error for{ f() { } }and{ f: function () { } }but not for{ f: () => { } }.sandersn commentedon May 13, 2022
Broken by #33767
sandersn commentedon May 13, 2022
I'm not sure what the right long-term fix is, but the short-term fix is to remove
bigintfrom es5.d.ts.sandersn commentedon May 13, 2022
The current behaviour for
BigIntis to fall back to{}wheninterface BigIntis not declared globally. Additionally, issue an error when target >= es2020.Some better fixes:
(1) is probably separate from (2-4). I don't know what should be allowed here -- for example, as long as the emit for es2020 doesn't rely on es2015 stdlib declarations, it should be fine to have target=es2020 and lib=es5.