Vue: Allow BigInt usage in templates

Created on 18 Feb 2020  路  9Comments  路  Source: vuejs/vue

What problem does this feature solve?

It would allow us to use numbers which is larger than MAX_SAFE_INTEGER.

What does the proposed API look like?

In HTML, {{BigInt("100")}}, {{100n}}, {{2n * 50n}} or {{50n + 50n}} should show "100" (it can be just simply string by using .toString()) at frontend.
At the moment using BigInt in "Mustache" syntax just throw error.
Sure, backup solution would be using external functions or converted into string and save it to variable. But using BigInt directly in HTML would be nice to have.
More Information about BigInt -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

feature request good first issue has PR

Most helpful comment

BigInt could be added to the other allowed variables like Number in templates. It will only be supported by browsers supporting it though

All 9 comments

BigInt could be added to the other allowed variables like Number in templates. It will only be supported by browsers supporting it though

BigInt has already good (still not large enough, Safari is still missing) cross browser support.
https://caniuse.com/#search=bigint
So perhaps this feature could be implemented as experimental.

Hi @posva can i begin working on this? What steps could i take in working on this also.
Thank you

Hi @posva, I'd like to work on this issue if that's alright?

Hello, I have created a pull request for this feature!
If there are anything wrong in this pull request, I will fix them.

Oh, no problem.
Sounds great!

鏋滅劧杩樻槸楂樻繁鑾祴

BigInt has already good (still not large enough, Safari is still missing) cross browser support.

@YanDevDe Safari 14 beta now has BigInt support.

https://github.com/disscussion-room join this organisation and you can discuss there.

Was this page helpful?
0 / 5 - 0 ratings