Skip to content

Type 'BigInt' cannot be used as an index type #50217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philippotto opened this issue Aug 8, 2022 · 2 comments
Closed

Type 'BigInt' cannot be used as an index type #50217

philippotto opened this issue Aug 8, 2022 · 2 comments

Comments

@philippotto
Copy link

philippotto commented Aug 8, 2022

Bug Report

🔎 Search Terms

BigInt, indexing, Type 'BigInt' does not satisfy the constraint 'string | number | symbol'.

🕗 Version & Regression Information

  • This is the behavior in every version I tried (that supports BigInt), and I reviewed the FAQ for entries about BigInt

⏯ Playground Link

Playground link with relevant code

💻 Code

const num: bigint = 50000000000000n;
const record: Record<bigint, bigint> = {};

record[num] = num;

console.log(record[num] + 10n);

🙁 Actual behavior

TypeScript reports three errors:

Type 'BigInt' does not satisfy the constraint 'string | number | symbol'.
Type 'BigInt' cannot be used as an index type.
Type 'BigInt' cannot be used as an index type.

🙂 Expected behavior

No errors should be reported as BigInts can in fact be used as an index type in JS.

@MartinJohns
Copy link
Contributor

Duplicate of #46395. Used search terms: bigint in:title

@philippotto
Copy link
Author

Sorry about that! Since the exact search for the error messages ("BigInt cannot be used as an index type." and 'BigInt' does not satisfy the constraint 'string | number | symbol') didn't bring up anything, I assumed, that this wasn't reported yet. I'll close this duplicate now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants