microsoft / microsoft/TypeScript
'bigint' is not comparable to 'number' with loose equality
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.3.3
Search Terms: bigin == number not comparable loose equality
Code
1n == 1
error:
This condition will always return 'false' since the types 'bigint' and 'number' have no overlap.
but in chrome 72.0.3626.121
> 1n == 1
< true
and in MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

And similar issues
let x = [1, 2, 3]
x[1n]
error:
Type '1n' cannot be used as an index type.
in Chrome
> let x = [1, 2, 3]
x[1n]
< 2
Playground Link:
http://www.typescriptlang.org/play/index.html#src=1n%20%3D%3D%201
http://www.typescriptlang.org/play/index.html#src=let%20x%20%3D%20%5B1%2C%202%2C%203%5D%0D%0Ax%5B1n%5D
Related Issues:
https://github.com/Microsoft/TypeScript/issues/30655
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two TypeScript 3.3.3 reproductions in the issue: loose equality between 1n and 1, and indexing an array with 1n. Compare the reported TypeScript errors with the Chrome and MDN behavior, then review related issue #30655. Done means the intended BigInt behavior is resolved consistently for both examples and verified with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100