Do not use lookahead when parsing imports in declare module in flow (#9987)
This commit is contained in:
parent
c2d303f8be
commit
5661de5908
@ -291,14 +291,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
let bodyNode = this.startNode();
|
let bodyNode = this.startNode();
|
||||||
|
|
||||||
if (this.match(tt._import)) {
|
if (this.match(tt._import)) {
|
||||||
const lookahead = this.lookahead();
|
this.next();
|
||||||
if (lookahead.value !== "type" && lookahead.value !== "typeof") {
|
if (!this.isContextual("type") && !this.isContextual("typeof")) {
|
||||||
this.unexpected(
|
this.unexpected(
|
||||||
null,
|
this.state.lastTokStart,
|
||||||
"Imports within a `declare module` body must always be `import type` or `import typeof`",
|
"Imports within a `declare module` body must always be `import type` or `import typeof`",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.next();
|
|
||||||
this.parseImport(bodyNode);
|
this.parseImport(bodyNode);
|
||||||
} else {
|
} else {
|
||||||
this.expectContextual(
|
this.expectContextual(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user