-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Accept bigints in t.bigIntLiteral factory
#17378
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
67febc8
breaking: store BigIntLiteral#value as bigint
JLHwung d3ce25c
update babel-types test cases
JLHwung e66c7bb
update babel-parser test fixtures
JLHwung 62044e3
feat: support bigint and deprecate string in the bigIntLiteral builder
JLHwung abc5a8a
make node 8 happy
JLHwung 8f0d647
update NodePart typing
JLHwung e98cc59
address review comments
JLHwung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2020/bigint/decimal-as-property-name-babel-7/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ({ 0n: 0, 1n() {}, get 2n(){}, set 3n(_){}, async 4n() {}, *5n() {} }); |
3 changes: 3 additions & 0 deletions
3
...es/babel-parser/test/fixtures/es2020/bigint/decimal-as-property-name-babel-7/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": false | ||
| } |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2020/bigint/decimal-as-property-name/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": true | ||
| } |
224 changes: 224 additions & 0 deletions
224
...es/babel-parser/test/fixtures/es2020/bigint/decimal-as-property-name/output.extended.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,224 @@ | ||
| { | ||
| "type": "File", | ||
| "start":0,"end":71,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":71,"index":71}}, | ||
| "program": { | ||
| "type": "Program", | ||
| "start":0,"end":71,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":71,"index":71}}, | ||
| "sourceType": "script", | ||
| "interpreter": null, | ||
| "body": [ | ||
| { | ||
| "type": "ExpressionStatement", | ||
| "start":0,"end":71,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":71,"index":71}}, | ||
| "expression": { | ||
| "type": "ObjectExpression", | ||
| "start":1,"end":69,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":69,"index":69}}, | ||
| "properties": [ | ||
| { | ||
| "type": "ObjectProperty", | ||
| "start":3,"end":8,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":8,"index":8}}, | ||
| "method": false, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":3,"end":5,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":5,"index":5}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "0" | ||
| }, | ||
| "raw": "0n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "0" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "shorthand": false, | ||
| "value": { | ||
| "type": "NumericLiteral", | ||
| "start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8}}, | ||
| "extra": { | ||
| "rawValue": 0, | ||
| "raw": "0" | ||
| }, | ||
| "value": 0 | ||
| } | ||
| }, | ||
| { | ||
| "type": "ObjectMethod", | ||
| "start":10,"end":17,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":17,"index":17}}, | ||
| "method": true, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":10,"end":12,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":12,"index":12}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "1" | ||
| }, | ||
| "raw": "1n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "1" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "kind": "method", | ||
| "id": null, | ||
| "generator": false, | ||
| "async": false, | ||
| "params": [], | ||
| "body": { | ||
| "type": "BlockStatement", | ||
| "start":15,"end":17,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":17,"index":17}}, | ||
| "body": [], | ||
| "directives": [] | ||
| } | ||
| }, | ||
| { | ||
| "type": "ObjectMethod", | ||
| "start":19,"end":29,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":29,"index":29}}, | ||
| "method": false, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":23,"end":25,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":25,"index":25}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "2" | ||
| }, | ||
| "raw": "2n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "2" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "kind": "get", | ||
| "id": null, | ||
| "generator": false, | ||
| "async": false, | ||
| "params": [], | ||
| "body": { | ||
| "type": "BlockStatement", | ||
| "start":27,"end":29,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":29,"index":29}}, | ||
| "body": [], | ||
| "directives": [] | ||
| } | ||
| }, | ||
| { | ||
| "type": "ObjectMethod", | ||
| "start":31,"end":42,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":42,"index":42}}, | ||
| "method": false, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":35,"end":37,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":37,"index":37}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "3" | ||
| }, | ||
| "raw": "3n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "3" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "kind": "set", | ||
| "id": null, | ||
| "generator": false, | ||
| "async": false, | ||
| "params": [ | ||
| { | ||
| "type": "Identifier", | ||
| "start":38,"end":39,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":39,"index":39},"identifierName":"_"}, | ||
| "name": "_" | ||
| } | ||
| ], | ||
| "body": { | ||
| "type": "BlockStatement", | ||
| "start":40,"end":42,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":42,"index":42}}, | ||
| "body": [], | ||
| "directives": [] | ||
| } | ||
| }, | ||
| { | ||
| "type": "ObjectMethod", | ||
| "start":44,"end":57,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":57,"index":57}}, | ||
| "method": true, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":50,"end":52,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":52,"index":52}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "4" | ||
| }, | ||
| "raw": "4n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "4" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "kind": "method", | ||
| "id": null, | ||
| "generator": false, | ||
| "async": true, | ||
| "params": [], | ||
| "body": { | ||
| "type": "BlockStatement", | ||
| "start":55,"end":57,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":57,"index":57}}, | ||
| "body": [], | ||
| "directives": [] | ||
| } | ||
| }, | ||
| { | ||
| "type": "ObjectMethod", | ||
| "start":59,"end":67,"loc":{"start":{"line":1,"column":59,"index":59},"end":{"line":1,"column":67,"index":67}}, | ||
| "method": true, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":60,"end":62,"loc":{"start":{"line":1,"column":60,"index":60},"end":{"line":1,"column":62,"index":62}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "5" | ||
| }, | ||
| "raw": "5n" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "5" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "kind": "method", | ||
| "id": null, | ||
| "generator": true, | ||
| "async": false, | ||
| "params": [], | ||
| "body": { | ||
| "type": "BlockStatement", | ||
| "start":65,"end":67,"loc":{"start":{"line":1,"column":65,"index":65},"end":{"line":1,"column":67,"index":67}}, | ||
| "body": [], | ||
| "directives": [] | ||
| } | ||
| } | ||
| ], | ||
| "extra": { | ||
| "parenthesized": true, | ||
| "parenStart": 0 | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "directives": [] | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2020/bigint/hex-as-property-name-babel-7/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ({ 0xbeefban: 0 }); |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2020/bigint/hex-as-property-name-babel-7/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": false | ||
| } |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2020/bigint/hex-as-property-name/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": true | ||
| } |
58 changes: 58 additions & 0 deletions
58
packages/babel-parser/test/fixtures/es2020/bigint/hex-as-property-name/output.extended.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "type": "File", | ||
| "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, | ||
| "program": { | ||
| "type": "Program", | ||
| "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, | ||
| "sourceType": "script", | ||
| "interpreter": null, | ||
| "body": [ | ||
| { | ||
| "type": "ExpressionStatement", | ||
| "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":19,"index":19}}, | ||
| "expression": { | ||
| "type": "ObjectExpression", | ||
| "start":1,"end":17,"loc":{"start":{"line":1,"column":1,"index":1},"end":{"line":1,"column":17,"index":17}}, | ||
| "properties": [ | ||
| { | ||
| "type": "ObjectProperty", | ||
| "start":3,"end":15,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":15,"index":15}}, | ||
| "method": false, | ||
| "key": { | ||
| "type": "BigIntLiteral", | ||
| "start":3,"end":12,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":12,"index":12}}, | ||
| "extra": { | ||
| "rawValue": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "12513210" | ||
| }, | ||
| "raw": "0xbeefban" | ||
| }, | ||
| "value": { | ||
| "$$ babel internal serialized type": "bigint", | ||
| "value": "12513210" | ||
| } | ||
| }, | ||
| "computed": false, | ||
| "shorthand": false, | ||
| "value": { | ||
| "type": "NumericLiteral", | ||
| "start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15}}, | ||
| "extra": { | ||
| "rawValue": 0, | ||
| "raw": "0" | ||
| }, | ||
| "value": 0 | ||
| } | ||
| } | ||
| ], | ||
| "extra": { | ||
| "parenthesized": true, | ||
| "parenStart": 0 | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "directives": [] | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2020/bigint/invalid-decimal-babel-7/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1.0n |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2020/bigint/invalid-decimal-babel-7/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": false | ||
| } |
29 changes: 29 additions & 0 deletions
29
packages/babel-parser/test/fixtures/es2020/bigint/invalid-decimal-babel-7/output.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "type": "File", | ||
| "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, | ||
| "errors": [ | ||
| "SyntaxError: Invalid BigIntLiteral. (1:0)" | ||
| ], | ||
| "program": { | ||
| "type": "Program", | ||
| "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, | ||
| "sourceType": "script", | ||
| "interpreter": null, | ||
| "body": [ | ||
| { | ||
| "type": "ExpressionStatement", | ||
| "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, | ||
| "expression": { | ||
| "type": "BigIntLiteral", | ||
| "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, | ||
| "extra": { | ||
| "rawValue": "1.0", | ||
| "raw": "1.0n" | ||
| }, | ||
| "value": "1.0" | ||
| } | ||
| } | ||
| ], | ||
| "directives": [] | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/es2020/bigint/invalid-decimal/options.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "BABEL_8_BREAKING": true | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it should be
string | bigintnow, but maybe nobody noticed and it's fine to keep it the way it is.