Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow bigInt in method name and TSLiteralType (#11547)
* refactor: add isLiteralPropertyName to parser utils * address review comments [skip-ci] * refactor: keyword is valid identifierName * fix: allow bigint in TSLiteralType * update typescript test whitelist
- Loading branch information
Showing
11 changed files
with
270 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/es2020/bigint/decimal-as-property-name/input.js
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
({ 0n: 0 }); | ||
({ 0n: 0, 1n() {}, get 2n(){}, set 3n(_){}, async 4n() {}, *5n() {} }); |
This file contains 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/typescript/types/literal-bigint-negative/input.ts
This file contains 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 @@ | ||
let x: -1n; |
53 changes: 53 additions & 0 deletions
53
packages/babel-parser/test/fixtures/typescript/types/literal-bigint-negative/output.json
This file contains 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,53 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":10,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":10}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":10,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":10},"identifierName":"x"}, | ||
"name": "x", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10}}, | ||
"typeAnnotation": { | ||
"type": "TSLiteralType", | ||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}}, | ||
"literal": { | ||
"type": "UnaryExpression", | ||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}}, | ||
"operator": "-", | ||
"prefix": true, | ||
"argument": { | ||
"type": "BigIntLiteral", | ||
"start":8,"end":10,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":10}}, | ||
"extra": { | ||
"rawValue": "1", | ||
"raw": "1n" | ||
}, | ||
"value": "1" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/typescript/types/literal-bigint/input.ts
This file contains 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 @@ | ||
let x: 0n; |
47 changes: 47 additions & 0 deletions
47
packages/babel-parser/test/fixtures/typescript/types/literal-bigint/output.json
This file contains 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,47 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":9,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":9}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":9,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":9},"identifierName":"x"}, | ||
"name": "x", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}}, | ||
"typeAnnotation": { | ||
"type": "TSLiteralType", | ||
"start":7,"end":9,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":9}}, | ||
"literal": { | ||
"type": "BigIntLiteral", | ||
"start":7,"end":9,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":9}}, | ||
"extra": { | ||
"rawValue": "0", | ||
"raw": "0n" | ||
}, | ||
"value": "0" | ||
} | ||
} | ||
} | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
This file contains 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 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