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

Do not record trailing comma pos when maybeAsyncArrow: false #10940

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

addTrailingCommaExtraToNode(node: N.Node): void {
addTrailingCommaExtraToNode(node: Undone<N.Node>): void {
this.addExtra(node, "trailingComma", this.state.lastTokStart);
this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
}
Expand Down
Expand Up @@ -18,9 +18,6 @@
"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
Expand Up @@ -18,9 +18,6 @@
"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
Expand Up @@ -18,9 +18,6 @@
"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
Expand Up @@ -21,9 +21,6 @@
"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
Expand Up @@ -20,9 +20,6 @@
"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
Expand Up @@ -17,9 +17,6 @@
"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 @@ -43,9 +40,6 @@
"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
Expand Up @@ -17,9 +17,6 @@
"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 @@ -43,9 +40,6 @@
"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
Expand Up @@ -17,9 +17,6 @@
"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 @@ -43,9 +40,6 @@
"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
Expand Up @@ -17,9 +17,6 @@
"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 @@ -43,9 +40,6 @@
"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
Expand Up @@ -17,9 +17,6 @@
"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 @@ -43,9 +40,6 @@
"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