Do not use lookahead when parsing imports in declare module in flow (#9987)

This commit is contained in:
Daniel Tschinder 2019-05-16 02:31:37 -07:00 committed by GitHub
parent c2d303f8be
commit 5661de5908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(