Skip to content
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

Support [jstype = JS_NUMBER] for int64 #292

Closed
pzeinlinger opened this issue Nov 7, 2022 · 3 comments
Closed

Support [jstype = JS_NUMBER] for int64 #292

pzeinlinger opened this issue Nov 7, 2022 · 3 comments

Comments

@pzeinlinger
Copy link

protobuf-ts has an option to use Number to represent int64 fields which is often very convenient where int32 2^32 size is not enough to represent a value, but Javascript's MAX_SAFE_INTEGER (2^53) certainly is.

In my case, this happens when dealing with accounting and money.

@smaye81
Copy link
Member

smaye81 commented Nov 14, 2022

Hi, @pzeinlinger. Sorry for the delay. It was actually a conscious decision to not allow this. I see your point, but it's obviously only effective if you can guarantee that no number in that field will ever exceed JavaScript's MAX_SAFE_INTEGER. This may be the case in your scenario, but it could lead to others encountering subtle bugs. Can you provide more detail on why an int64 doesn't meet your needs?

@smaye81
Copy link
Member

smaye81 commented Nov 22, 2022

@pzeinlinger going to close this issue as this is something we don't plan to support. If you have any other issues or comments, feel free to reopen.

@smaye81 smaye81 closed this as completed Nov 22, 2022
@shartte
Copy link

shartte commented Nov 11, 2024

This is somewhat disappointing since I was hoping to use this for a field that is used for "millis since epoch" in our schemas.
Having to roundtrip these values via BigInt is a performance concern.
And yes, millis since epoch is number safe given Date#getTime has that particular return type for the same domain.

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

3 participants