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
add support for new type: bigint #6639
Comments
Parsing side of this feature was imported in #7471. |
Summary: <!-- If this is a change to library defintions, please include links to relevant documentation. If this is a documentation change, please prefix the title with [DOCS]. If this is neither, ensure you opened a discussion issue and link it in the PR description. --> Proposal: https://github.com/tc39/proposal-bigint Discussion: #6639 This probably can be discussion? Also `typeof` should support `bigint` but I don't know how to add it Parsing errors: ![image](https://user-images.githubusercontent.com/3275424/52748292-f54ed780-3007-11e9-9185-bd1446dfb357.png) Type errors: ![image](https://user-images.githubusercontent.com/3275424/52748417-4959bc00-3008-11e9-887f-c1a7a1e3f9da.png) Pull Request resolved: #7471 Reviewed By: nmote Differential Revision: D14524589 Pulled By: gabelevi fbshipit-source-id: bc8f4a970f60259dd1dcd1a3c92f0a51f0aadfeb
This should be resolved, so I'm going to close this. |
@dsainati1 there is still typechecking part, only parsing was implemented |
When can we expect this? |
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding hte basic Grain type, I exported a `format` function which will display Grain balances in a human readable way (i.e. stripping most of the precision). This is both a useful method, and an example of how to use the Grain type and work around flow issues. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way (i.e. stripping most of the precision). This is both a useful method, and an example of how to use the Grain type and work around flow issues. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639 Thanks to @Beanow and @HammadJ and @burrrata for feedback on how much decimal precision to use.
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way (i.e. stripping most of the precision). This is both a useful method, and an example of how to use the Grain type and work around flow issues. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639 Thanks to @Beanow and @HammadJ and @burrrata for feedback on how much decimal precision to use.
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way. It supports arbitrary decimal precision, groups large amounts with comma separators, handles negative numbers, and adds a suffix string. The format method is thoroughly documented and tested. Thanks to @Beanow for valuable feedback on its implementation. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way. It supports arbitrary decimal precision, groups large amounts with comma separators, handles negative numbers, and adds a suffix string. The format method is thoroughly documented and tested. Thanks to @Beanow for valuable feedback on its implementation. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way. It supports arbitrary decimal precision, groups large amounts with comma separators, handles negative numbers, and adds a suffix string. The format method is thoroughly documented and tested. Thanks to @Beanow for valuable feedback on its implementation. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639
This commit adds a `grain/grain.js` module, which contains a type and logic for representing Grain balances with 18 digits of precision. We use the native BigInt type (and add the necessary babel plugin to support it). Unfortunately, Flow does not yet support BigInts (see [facebook/flow#6639]). To hack around this, we lie to Flow, claiming that BigInts are numbers, and we expect/suppress the flow errors whenever we actually instantiate one. For example: ```js // $ExpectFlowError const myBigInt = 5n; ``` We can use the BigInt operators like `+`, `-`, `>` without flow errors, since these actually exist on numbers too. However, flow will fail to detect improper combinations of regular numbers and BigInts: ```js // $ExpectFlowError const x = 5n; const y = x + 5; // Uncaught TypeError: Cannot mix BigInt and other types ``` Since any improper mixing will result in a runtime error, these issues will be easy to detect via unit tests. In addition to adding the basic Grain type, I exported a `format` function which will display Grain balances in a human readable way. It supports arbitrary decimal precision, groups large amounts with comma separators, handles negative numbers, and adds a suffix string. The format method is thoroughly documented and tested. Thanks to @Beanow for valuable feedback on its implementation. Test plan: See included unit tests. `yarn test` passes. [facebook/flow#6639]: facebook/flow#6639
BigInt support would really help with a project I'm working on. |
Can we first have support for |
I'm still getting the error cc @mroch any insight? 🙏 |
BigInt is now supported as of 0.194 |
https://flow.org/try/#0BQRgdgXABARglgczmALgSiA
The text was updated successfully, but these errors were encountered: