Skip to content

Commit

Permalink
fix flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Nov 12, 2021
1 parent 4a26879 commit 1c1b938
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -73,6 +73,7 @@ import { cloneIdentifier } from "./node";

/*::
import type { SourceType } from "../options";
declare var invariant;
*/

const invalidHackPipeBodies = new Map([
Expand Down Expand Up @@ -841,13 +842,14 @@ export default class ExpressionParser extends LValParser {

let node = this.startNodeAt(startPos, startLoc);
node.callee = base;
const { maybeAsyncArrow, optionalChainMember } = state;

if (state.maybeAsyncArrow) {
if (maybeAsyncArrow) {
this.expressionScope.enter(newAsyncArrowScope());
refExpressionErrors = new ExpressionErrors();
}

if (state.optionalChainMember) {
if (optionalChainMember) {
node.optional = optional;
}

Expand All @@ -862,9 +864,10 @@ export default class ExpressionParser extends LValParser {
refExpressionErrors,
);
}
this.finishCallExpression(node, state.optionalChainMember);
this.finishCallExpression(node, optionalChainMember);

if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
/*:: invariant(refExpressionErrors != null) */
state.stop = true;
this.checkDestructuringPrivate(refExpressionErrors);
this.expressionScope.validateAsPattern();
Expand All @@ -874,7 +877,7 @@ export default class ExpressionParser extends LValParser {
node,
);
} else {
if (state.maybeAsyncArrow) {
if (maybeAsyncArrow) {
this.checkExpressionErrors(refExpressionErrors, true);
this.expressionScope.exit();
}
Expand Down Expand Up @@ -2235,7 +2238,7 @@ export default class ExpressionParser extends LValParser {
case tt.privateName: {
// the class private key has been handled in parseClassElementName
const privateKeyPos = this.state.start;
if (refExpressionErrors !== undefined) {
if (refExpressionErrors != null) {
if (refExpressionErrors.privateKey === -1) {
refExpressionErrors.privateKey = privateKeyPos;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-parser/src/parser/lval.js
Expand Up @@ -16,6 +16,7 @@ import type {
/*:: ObjectMember, */
/*:: TsNamedTypeElementBase, */
/*:: Identifier, */
/*:: PrivateName, */
/*:: ObjectExpression, */
/*:: ObjectPattern, */
} from "../types";
Expand Down Expand Up @@ -63,6 +64,7 @@ export default class LValParser extends NodeUtils {
+parsePropertyName: (
prop: ObjectOrClassMember | ClassMember | TsNamedTypeElementBase,
) => Expression | Identifier;
+parsePrivateName: () => PrivateName
*/
// Forward-declaration: defined in statement.js
/*::
Expand Down

0 comments on commit 1c1b938

Please sign in to comment.