babylon
Advanced tools
Comparing version 5.8.20 to 5.8.21
@@ -164,4 +164,7 @@ // A recursive descent parser operates by defining functions for all | ||
var expr = this.parseMaybeUnary(refShorthandDefaultPos); | ||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr; | ||
return this.parseExprOp(expr, startPos, startLoc, -1, noIn); | ||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) { | ||
return expr; | ||
} else { | ||
return this.parseExprOp(expr, startPos, startLoc, -1, noIn); | ||
} | ||
}; | ||
@@ -212,2 +215,3 @@ | ||
} | ||
var startPos = this.state.start, | ||
@@ -339,3 +343,2 @@ startLoc = this.state.startLoc; | ||
// | ||
if (this.options.features["es7.asyncFunctions"]) { | ||
@@ -342,0 +345,0 @@ if (id.name === "await") { |
@@ -167,3 +167,2 @@ "use strict"; | ||
var node = this.startNodeAt(startPos, startLoc); | ||
node.operator = "="; | ||
node.left = left; | ||
@@ -170,0 +169,0 @@ node.right = this.parseMaybeAssign(); |
@@ -659,5 +659,5 @@ "use strict"; | ||
this.parseExportSpecifiersMaybe(node); | ||
this.parseExportFrom(node); | ||
this.parseExportFrom(node, true); | ||
} else { | ||
this.parseExportFrom(node); | ||
this.parseExportFrom(node, true); | ||
return this.finishNode(node, "ExportAllDeclaration"); | ||
@@ -679,8 +679,9 @@ } | ||
} | ||
this.parseExportFrom(node); | ||
this.parseExportFrom(node, true); | ||
} else if (this.eat(_tokenizerTypes.types._default)) { | ||
// export default ... | ||
var possibleDeclaration = this.match(_tokenizerTypes.types._function) || this.match(_tokenizerTypes.types._class); | ||
var expr = this.parseMaybeAssign(); | ||
var needsSemi = true; | ||
if (expr.type === "FunctionExpression" || expr.type === "ClassExpression") { | ||
if (possibleDeclaration) { | ||
needsSemi = false; | ||
@@ -696,5 +697,5 @@ if (expr.id) { | ||
} else if (this.state.type.keyword || this.shouldParseExportDeclaration()) { | ||
node.declaration = this.parseStatement(true); | ||
node.specifiers = []; | ||
node.source = null; | ||
node.declaration = this.parseExportDeclaration(node); | ||
} else { | ||
@@ -704,8 +705,3 @@ // export { x, y as z } [from '...'] | ||
node.specifiers = this.parseExportSpecifiers(); | ||
if (this.eatContextual("from")) { | ||
node.source = this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.unexpected(); | ||
} else { | ||
node.source = null; | ||
} | ||
this.semicolon(); | ||
this.parseExportFrom(node); | ||
} | ||
@@ -716,2 +712,6 @@ this.checkExport(node); | ||
pp.parseExportDeclaration = function () { | ||
return this.parseStatement(true); | ||
}; | ||
pp.isExportDefaultSpecifier = function () { | ||
@@ -736,7 +736,15 @@ if (this.match(_tokenizerTypes.types.name)) { | ||
pp.parseExportFrom = function (node) { | ||
this.expectContextual("from"); | ||
node.source = this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.unexpected(); | ||
pp.parseExportFrom = function (node, expect) { | ||
if (this.eatContextual("from")) { | ||
node.source = this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.unexpected(); | ||
this.checkExport(node); | ||
} else { | ||
if (expect) { | ||
this.unexpected(); | ||
} else { | ||
node.source = null; | ||
} | ||
} | ||
this.semicolon(); | ||
this.checkExport(node); | ||
}; | ||
@@ -743,0 +751,0 @@ |
@@ -677,2 +677,35 @@ "use strict"; | ||
instance.extend("parseExport", function (inner) { | ||
return function (node) { | ||
node = inner.call(this, node); | ||
if (node.type === "ExportNamedDeclaration") { | ||
node.exportKind = node.exportKind || "value"; | ||
} | ||
return node; | ||
}; | ||
}); | ||
instance.extend("parseExportDeclaration", function (inner) { | ||
return function (node) { | ||
if (this.isContextual("type")) { | ||
node.exportKind = "type"; | ||
var declarationNode = this.startNode(); | ||
this.next(); | ||
if (this.match(_tokenizerTypes.types.braceL)) { | ||
// export type { foo, bar }; | ||
node.specifiers = this.parseExportSpecifiers(); | ||
this.parseExportFrom(node); | ||
return null; | ||
} else { | ||
// export type Foo = Bar; | ||
return this.flowParseTypeAlias(declarationNode); | ||
} | ||
} else { | ||
return inner.call(this, node); | ||
} | ||
}; | ||
}); | ||
instance.extend("parseClassId", function (inner) { | ||
@@ -813,2 +846,4 @@ return function (node, isStatement) { | ||
var typeParameters; | ||
// method shorthand | ||
if (this.isRelational("<")) { | ||
@@ -818,4 +853,9 @@ typeParameters = this.flowParseTypeParameterDeclaration(); | ||
} | ||
inner.apply(this, arguments); | ||
prop.value.typeParameters = typeParameters; | ||
// add typeParameters if we found them | ||
if (typeParameters) { | ||
prop.value.typeParameters = typeParameters; | ||
} | ||
}; | ||
@@ -822,0 +862,0 @@ }); |
{ | ||
"name": "babylon", | ||
"version": "5.8.20", | ||
"version": "5.8.21", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185795
4684