Add support for Flow shorthand import type (#267)

This commit is contained in:
Jeff Morrison
2017-01-03 04:52:18 -05:00
committed by Daniel Tschinder
parent 68bb1c6598
commit 9ea4e9dead
6 changed files with 1032 additions and 5 deletions

View File

@@ -1061,14 +1061,18 @@ pp.parseImportSpecifiers = function (node) {
if (this.eat(tt.braceR)) break;
}
let specifier = this.startNode();
specifier.imported = this.parseIdentifier(true);
specifier.local = this.eatContextual("as") ? this.parseIdentifier() : specifier.imported.__clone();
this.checkLVal(specifier.local, true, undefined, "import specifier");
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
this.parseImportSpecifier(node);
}
};
pp.parseImportSpecifier = function (node) {
let specifier = this.startNode();
specifier.imported = this.parseIdentifier(true);
specifier.local = this.eatContextual("as") ? this.parseIdentifier() : specifier.imported.__clone();
this.checkLVal(specifier.local, true, undefined, "import specifier");
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
};
pp.parseImportSpecifierDefault = function (id, startPos, startLoc) {
let node = this.startNodeAt(startPos, startLoc);
node.local = id;