prefer-bigint-literals: Support signed numbers and strings#2784
Conversation
prefer-bigint-literals): fix add support for numbers/strings with operators
|
I opened #2733, because I think there are maybe people writes |
|
I didn't notice, this is a PR, not an issue. Sorry! |
|
|
||
| // BigInt("+1") -> 1n | ||
| if (raw[0] === '+') { | ||
| raw = raw.slice(1); |
There was a problem hiding this comment.
Can you add test for BigInt("++1")?
There was a problem hiding this comment.
BigInt(" -1 ")
BigInt(" +1 ")
There was a problem hiding this comment.
added tests:
BigInt("++1") - valid
BigInt("+ 1") - valid
BigInt(" -1 ") - invalid
BigInt(" +1 ") - invalid with suggestion
|
Need test |
|
There can also ASI issue since the fixed code inserts |
fixed, added tests
not sure about this, but i think it is working fine? added test for this |
|
Another test |
|
Bump :) |
59c1ea2 to
1bd819c
Compare
1bd819c to
b8460db
Compare
|
Sorry, I mean |
|
I'm taking a final look. |
|
I pushed some simplification, can you take a look? |
| 'BigInt(1) + BigInt(2)', | ||
| 'BigInt(1) ** 2n', | ||
| 'condition ? BigInt(1) : BigInt(2)', | ||
| '+BigInt(1)', |
There was a problem hiding this comment.
Same runtime error, this is not what we should care.
+BigInt(1)
VM782:1 Uncaught TypeError: Cannot convert a BigInt value to a number
at <anonymous>:1:1
(anonymous) @ VM782:1
+1n
VM792:1 Uncaught TypeError: Cannot convert a BigInt value to a number
at <anonymous>:1:1
prefer-bigint-literals): fix add support for numbers/strings with operatorsprefer-bigint-literals: Support signed numbers and strings

Fixes #2733, added support for
BigInt('+1'),BigInt('-1'),BigInt(+1),BigInt(-1). Not sure aboutBigInt(!1)andBigInt(~1), looks like those also valid?