Skip to content

Commit

Permalink
Do not use lookahead when parsing imports in declare module in flow (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed May 16, 2019
1 parent c2d303f commit 5661de5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/babel-parser/src/plugins/flow.js
Expand Up @@ -291,14 +291,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let bodyNode = this.startNode();

if (this.match(tt._import)) {
const lookahead = this.lookahead();
if (lookahead.value !== "type" && lookahead.value !== "typeof") {
this.next();
if (!this.isContextual("type") && !this.isContextual("typeof")) {
this.unexpected(
null,
this.state.lastTokStart,
"Imports within a `declare module` body must always be `import type` or `import typeof`",
);
}
this.next();
this.parseImport(bodyNode);
} else {
this.expectContextual(
Expand Down

0 comments on commit 5661de5

Please sign in to comment.