Merge branch 'master' into feat-optional-chaining

This commit is contained in:
Henry Zhu
2017-05-31 14:33:47 -04:00
committed by GitHub
21 changed files with 1325 additions and 17 deletions

View File

@@ -459,6 +459,10 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "Super");
case tt._import:
if (this.hasPlugin("importMeta") && this.lookahead().type === tt.dot) {
return this.parseImportMetaProperty();
}
if (!this.hasPlugin("dynamicImport")) this.unexpected();
node = this.startNode();
@@ -620,12 +624,22 @@ export default class ExpressionParser extends LValParser {
node.property = this.parseIdentifier(true);
if (node.property.name !== propertyName) {
this.raise(node.property.start, `The only valid meta property for new is ${meta.name}.${propertyName}`);
this.raise(node.property.start, `The only valid meta property for ${meta.name} is ${meta.name}.${propertyName}`);
}
return this.finishNode(node, "MetaProperty");
}
parseImportMetaProperty(): N.MetaProperty {
const node = this.startNode();
const id = this.parseIdentifier(true);
this.expect(tt.dot);
if (!this.inModule) {
this.raise(id.start, "import.meta may appear only with 'sourceType: module'");
}
return this.parseMetaProperty(node, id, "meta");
}
parseLiteral<T : N.Literal>(value: any, type: /*T["kind"]*/string, startPos?: number, startLoc?: Position): T {
startPos = startPos || this.state.start;
startLoc = startLoc || this.state.startLoc;