-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Bigint literal type -0n
exists, and is not handled consistently
#60466
Comments
-0n
exists, and is not handled consistently-0n
exists, and is not handled consistently
Is this really specific to Is this really specific to The difference between I'm not seeing a bug here. The behavior where TS can only infer numbers from "round-trippable" strings is documented in the release notes and #48094, so one should expect |
I was not aware of these for the template types, thanks for the links. But so far, I still think that |
The type |
I don't understand what the bug is supposed to be here either. |
π Search Terms
bigint negative zero template
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?target=99&ts=5.6.3#code/C4TwDgpgBACg9gZwFoQE5ygXigBgHYDcAUKJFAHIQDmK6WUAtPgVK2+x5wPRdQD8AQiI82APT5EAxnDwJgUMAC8AXLES0M2JoSky5UPCorUN9ZkRLhoAZWCpKNNJqgADACQBvbQF8Xnf1AigsK8rOKWZLaoAEIAllQAknjy2O4eeACuALYARmi+urLyAB6qUXGJyfQAREzVLAEcQUIR0DAAhqgIEBVJwAA8ACpQEMXAEHgAJgiunjnxscm+AHz0w6PjUzNpiwBmaFB9I2MT01DzVIvAvvyHVap4EABuaK1qCLHAsS8A8o-0HS6PXifX6AHIAIxg5YhMQSUjQBztL6-f7YQHdXrJcEMKEwkRheFWd6fb4QUzozqYkHYsE4aGwwlvJEo8lOAFU4GVAZgpjQtjNRlQcRAA
π» Code
π Actual behavior
-0n
is a valid and evalutates to0n
, and"-0"
matches`${bigint}`
, but`${-0n}`
evalutates to"0"
, and"-0"
is not successfully inferred as0n
π Expected behavior
-0n
should either not exist, or it should be handled consistently with other bigint literals.Either:
-0n
should fail, and"-0"
should not match`${bigint}`
, because-0n
is not a valid bigint value, and thus no such bigint stringifies to-0
."-0"
should be inferred to contain0n
/-0n
, because-0n
is valid syntax that evalutates to0n
.Additional information about the issue
Credit to mkantor and sinclair in the TypeScript Community for extra examples.
The text was updated successfully, but these errors were encountered: