Fix some flow issues in @babel/parser flow plugin (#8002)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import type Parser from "../parser";
|
||||
import { types as tt, type TokenType } from "../tokenizer/types";
|
||||
import * as N from "../types";
|
||||
import type { Options } from "../options";
|
||||
import type { Pos, Position } from "../util/location";
|
||||
import type State from "../tokenizer/state";
|
||||
import * as charCodes from "charcodes";
|
||||
@@ -82,7 +83,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
|
||||
}
|
||||
|
||||
addComment(comment: Comment): void {
|
||||
addComment(comment: N.Comment): void {
|
||||
if (this.flowPragma === undefined) {
|
||||
// Try to parse a flow pragma.
|
||||
const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
|
||||
@@ -2455,6 +2456,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.callee = base;
|
||||
node.typeArguments = this.flowParseTypeParameterInstantiation();
|
||||
this.expect(tt.parenL);
|
||||
// $FlowFixMe
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||
node.optional = true;
|
||||
return this.finishNode(node, "OptionalCallExpression");
|
||||
@@ -2463,7 +2465,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
this.shouldParseTypes() &&
|
||||
this.isRelational("<")
|
||||
) {
|
||||
const node: N.CallExpression = this.startNodeAt(startPos, startLoc);
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = base;
|
||||
const state = this.state.clone();
|
||||
try {
|
||||
|
||||
@@ -547,6 +547,7 @@ export type ConditionalExpression = NodeBase & {
|
||||
export type CallOrNewBase = NodeBase & {
|
||||
callee: Expression | Super | Import,
|
||||
arguments: Array<Expression | SpreadElement>, // TODO: $ReadOnlyArray
|
||||
typeArguments: ?TypeParameterInstantiationBase,
|
||||
typeParameters?: ?TypeParameterInstantiationBase, // TODO: Not in spec
|
||||
};
|
||||
|
||||
@@ -936,6 +937,12 @@ export type FlowTypeAnnotation = Node;
|
||||
export type FlowVariance = Node;
|
||||
export type FlowClassImplements = Node;
|
||||
|
||||
export type FlowInterfaceType = NodeBase & {
|
||||
type: "FlowInterfaceType",
|
||||
extends: FlowInterfaceExtends,
|
||||
body: FlowObjectTypeAnnotation,
|
||||
};
|
||||
|
||||
// estree
|
||||
|
||||
export type EstreeProperty = NodeBase & {
|
||||
|
||||
Reference in New Issue
Block a user