Skip to content
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

Revert "Do not record trailing comma pos when maybeAsyncArrow: false" #15901

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/babel-parser/src/parser/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ export default abstract class ExpressionParser extends LValParser {
tt.parenR,
base.type === "Import",
base.type !== "Super",
maybeAsyncArrow ? node : null,
// @ts-expect-error todo(flow->ts)
node,
refExpressionErrors,
);
}
Expand Down Expand Up @@ -1007,7 +1008,7 @@ export default abstract class ExpressionParser extends LValParser {
close: TokenType,
dynamicImport?: boolean,
allowPlaceholder?: boolean,
nodeForExtra?: Undone<N.Node> | null,
nodeForExtra?: N.Node | null,
refExpressionErrors?: ExpressionErrors | null,
): Array<N.Expression | undefined | null> {
const elts: N.Expression[] = [];
Expand Down Expand Up @@ -2028,7 +2029,10 @@ export default abstract class ExpressionParser extends LValParser {
} else {
this.expect(tt.comma);
if (this.match(close)) {
this.addTrailingCommaExtraToNode(node);
this.addTrailingCommaExtraToNode(
// @ts-expect-error todo(flow->ts) improve node types
node,
);
break;
}
}
Expand Down Expand Up @@ -2071,7 +2075,7 @@ export default abstract class ExpressionParser extends LValParser {
return this.finishNode(node, type);
}

addTrailingCommaExtraToNode(node: Undone<N.Node>): void {
addTrailingCommaExtraToNode(node: N.Node): void {
this.addExtra(node, "trailingComma", this.state.lastTokStart);
this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"start":0,"end":2,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":2,"index":2},"identifierName":"fn"},
"name": "fn"
},
"extra": {
"trailingComma": 11
},
"arguments": [
{
"type": "Identifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"start":0,"end":2,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":2,"index":2},"identifierName":"fn"},
"name": "fn"
},
"extra": {
"trailingComma": 7
},
"arguments": [
{
"type": "Identifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3},"identifierName":"log"},
"name": "log"
},
"extra": {
"trailingComma": 13
},
"arguments": [
{
"type": "Identifier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"start":0,"end":3,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":3,"index":3},"identifierName":"log"},
"name": "log"
},
"extra": {
"trailingComma": 4
},
"arguments": [
null
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 12
},
"arguments": [
{
"type": "StringLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 15
},
"arguments": [
{
"type": "StringLiteral",
Expand All @@ -40,6 +43,9 @@
"type": "Import",
"start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}}
},
"extra": {
"trailingComma": 64
},
"arguments": [
{
"type": "StringLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 15
},
"arguments": [
{
"type": "StringLiteral",
Expand All @@ -40,6 +43,9 @@
"type": "Import",
"start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}}
},
"extra": {
"trailingComma": 66
},
"arguments": [
{
"type": "StringLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 15
},
"arguments": [
{
"type": "StringLiteral",
Expand All @@ -40,6 +43,9 @@
"type": "Import",
"start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}}
},
"extra": {
"trailingComma": 66
},
"arguments": [
{
"type": "StringLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 15
},
"arguments": [
{
"type": "StringLiteral",
Expand All @@ -40,6 +43,9 @@
"type": "Import",
"start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}}
},
"extra": {
"trailingComma": 64
},
"arguments": [
{
"type": "StringLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "Import",
"start":0,"end":6,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":6,"index":6}}
},
"extra": {
"trailingComma": 15
},
"arguments": [
{
"type": "StringLiteral",
Expand All @@ -40,6 +43,9 @@
"type": "Import",
"start":19,"end":25,"loc":{"start":{"line":2,"column":0,"index":19},"end":{"line":2,"column":6,"index":25}}
},
"extra": {
"trailingComma": 64
},
"arguments": [
{
"type": "StringLiteral",
Expand Down