-
Notifications
You must be signed in to change notification settings - Fork 55
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
Use typeof BigInt
to check for BigInt support
#488
Conversation
typeof BigInt
to check for BigInt support
Thanks for the PR @lukasIO. It's definitely unfortunate that It looks like we have a few other uses of |
Sure, I can do that! Should the unit tests go into the |
It depends what you are testing. Anything testing functionality in For running tests, you can run
Thanks again! |
I realised I'm not sure what you're looking for test wise regarding the changes in this PR. |
If we refer to |
would adding |
It should automatically avoid name clashes by generating a class named But this is technically a breaking change. If any user is using such a protobuf message, we break their generated code, which we definitely want to avoid. I don't have an immediate idea to solve this 🤔 |
Are you sure it would be a breaking change? Afaict using If |
Hi @lukasIO. Sorry for the delay, but we did some thinking on how best to solve this. To answer your question, it would be a breaking change. If we started generating a class name of However, we think we've come up with a way to remove the I think as far as this PR is concerned, you can revert your changes to |
This reverts commit 2fbca84.
nice! reverted the other changes. |
This removes the usage of `globalThis` in generated code by instead using an export of global `Number` constants. This is done so that we can safely use these global constants when generating code and be assured we're using the correct values. We cannot use `globalThis` since we support ES2017 and `globalThis` was introduced in ES2020. We also don't want to explicitly generate code using, for example, `Number.NaN`, since this could clash with a message name of `Number`. Instead we can export them in a local `proto-double.js` file since this will be in a different scope as the generated code and we are guaranteed to use the intended global values. Note that this complements #488 to remove usage of `globalThis` in the repo.
Let's change it to |
re: the CI failure, you just need to run |
hm, getting an error on
running |
Merged. Thanks for the PR @lukasIO! |
## What's Changed * Add `toPlainMessage` to convert `Message` objects to their `PlainMessage` variants by @srikrsna-buf in #511 * Remove usage of globalThis in generated code by @smaye81 in #504 * Use `typeof BigInt` to check for BigInt support by @lukasIO in #488 ## New Contributors * @lukasIO made their first contribution in #488. **Full Changelog**: https://github.com/bufbuild/protobuf-es/compare/v1.2.1..v1.3.0
fixes #486