Skip to content

Commit

Permalink
fix: add optional: false to chained optional call expression (#11814)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 10, 2020
1 parent f32d5de commit 02c8fd9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/babel-parser/src/parser/expression.js
Expand Up @@ -660,8 +660,10 @@ export default class ExpressionParser extends LValParser {
let node = this.startNodeAt(startPos, startLoc);
node.callee = base;

if (state.optionalChainMember) {
node.optional = optional;
}
if (optional) {
node.optional = true;
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
} else {
node.arguments = this.parseCallExpressionArguments(
Expand Down
Expand Up @@ -39,6 +39,7 @@
"computed": false,
"optional": true
},
"optional": false,
"arguments": []
}
}
Expand Down
Expand Up @@ -257,6 +257,7 @@
"computed": false,
"optional": false
},
"optional": false,
"arguments": [
{
"type": "NumericLiteral",
Expand Down Expand Up @@ -303,6 +304,7 @@
"computed": false,
"optional": false
},
"optional": false,
"arguments": []
}
]
Expand Down
Expand Up @@ -93,6 +93,7 @@
"computed": false,
"optional": true
},
"optional": false,
"arguments": []
}
}
Expand Down
Expand Up @@ -99,6 +99,7 @@
"computed": false,
"optional": false
},
"optional": false,
"arguments": [
{
"type": "NumericLiteral",
Expand Down

0 comments on commit 02c8fd9

Please sign in to comment.