@babel/plugin-transform-classes
Advanced tools
Comparing version 7.0.0-beta.34 to 7.0.0-beta.35
@@ -32,17 +32,2 @@ "use strict"; | ||
var verifyConstructorVisitor = _core.traverse.visitors.merge([noMethodVisitor, { | ||
MemberExpression: { | ||
exit: function exit(path) { | ||
var objectPath = path.get("object"); | ||
if (this.isDerived && !this.hasBareSuper && objectPath.isSuper()) { | ||
var hasArrowFunctionParent = path.findParent(function (p) { | ||
return p.isArrowFunctionExpression(); | ||
}); | ||
if (!hasArrowFunctionParent) { | ||
throw objectPath.buildCodeFrameError("'super.*' is not allowed before super()"); | ||
} | ||
} | ||
} | ||
}, | ||
CallExpression: { | ||
@@ -60,10 +45,13 @@ exit: function exit(path) { | ||
ThisExpression: function ThisExpression(path) { | ||
if (this.isDerived && !this.hasBareSuper) { | ||
var fn = path.find(function (p) { | ||
return p.isFunction(); | ||
}); | ||
if (this.isDerived) { | ||
if (path.parentPath.isMemberExpression({ | ||
object: path.node | ||
})) { | ||
return; | ||
} | ||
if (!fn || !fn.isArrowFunctionExpression()) { | ||
throw path.buildCodeFrameError("'this' is not allowed before super()"); | ||
} | ||
var assertion = _core.types.callExpression(this.file.addHelper("assertThisInitialized"), [path.node]); | ||
path.replaceWith(assertion); | ||
path.skip(); | ||
} | ||
@@ -260,2 +248,3 @@ } | ||
superRef: this.superName, | ||
inConstructor: isConstructor, | ||
isStatic: node.static, | ||
@@ -383,7 +372,2 @@ isLoose: this.isLoose, | ||
var body = path.get("body"); | ||
if (!this.hasBareSuper && !this.superReturns.length) { | ||
throw path.buildCodeFrameError("missing super() call in constructor"); | ||
} | ||
path.traverse(findThisesVisitor, this); | ||
@@ -425,3 +409,3 @@ var guaranteedSuperBeforeFinish = !!this.bareSupers.length; | ||
if (parentPath.isLoop() || parentPath.isConditional()) { | ||
if (parentPath.isLoop() || parentPath.isConditional() || parentPath.isArrowFunctionExpression()) { | ||
guaranteedSuperBeforeFinish = false; | ||
@@ -455,3 +439,5 @@ return true; | ||
wrapReturn = function wrapReturn(returnArg) { | ||
return returnArg ? _core.types.logicalExpression("||", returnArg, _thisRef()) : _thisRef(); | ||
var thisExpr = _core.types.callExpression(_this2.file.addHelper("assertThisInitialized"), [_thisRef()]); | ||
return returnArg ? _core.types.logicalExpression("||", returnArg, thisExpr) : thisExpr; | ||
}; | ||
@@ -466,3 +452,3 @@ } else { | ||
if (bodyPaths.length && !bodyPaths.pop().isReturnStatement()) { | ||
if (!bodyPaths.length || !bodyPaths.pop().isReturnStatement()) { | ||
body.pushContainer("body", _core.types.returnStatement(guaranteedSuperBeforeFinish ? _thisRef() : wrapReturn())); | ||
@@ -469,0 +455,0 @@ } |
{ | ||
"name": "@babel/plugin-transform-classes", | ||
"version": "7.0.0-beta.34", | ||
"version": "7.0.0-beta.35", | ||
"description": "Compile ES2015 classes to ES5", | ||
@@ -9,7 +9,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes", | ||
"dependencies": { | ||
"@babel/helper-annotate-as-pure": "7.0.0-beta.34", | ||
"@babel/helper-define-map": "7.0.0-beta.34", | ||
"@babel/helper-function-name": "7.0.0-beta.34", | ||
"@babel/helper-optimise-call-expression": "7.0.0-beta.34", | ||
"@babel/helper-replace-supers": "7.0.0-beta.34" | ||
"@babel/helper-annotate-as-pure": "7.0.0-beta.35", | ||
"@babel/helper-define-map": "7.0.0-beta.35", | ||
"@babel/helper-function-name": "7.0.0-beta.35", | ||
"@babel/helper-optimise-call-expression": "7.0.0-beta.35", | ||
"@babel/helper-replace-supers": "7.0.0-beta.35" | ||
}, | ||
@@ -20,8 +20,8 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.34" | ||
"@babel/core": "7.0.0-beta.35" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.34", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.34" | ||
"@babel/core": "7.0.0-beta.35", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.35" | ||
} | ||
} |
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
25915
539
+ Added@babel/code-frame@7.0.0-beta.35(transitive)
+ Added@babel/core@7.0.0-beta.35(transitive)
+ Added@babel/generator@7.0.0-beta.35(transitive)
+ Added@babel/helper-annotate-as-pure@7.0.0-beta.35(transitive)
+ Added@babel/helper-define-map@7.0.0-beta.35(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.35(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.35(transitive)
+ Added@babel/helper-optimise-call-expression@7.0.0-beta.35(transitive)
+ Added@babel/helper-replace-supers@7.0.0-beta.35(transitive)
+ Added@babel/helpers@7.0.0-beta.35(transitive)
+ Added@babel/template@7.0.0-beta.35(transitive)
+ Added@babel/traverse@7.0.0-beta.35(transitive)
+ Added@babel/types@7.0.0-beta.35(transitive)
+ Addedbabylon@7.0.0-beta.35(transitive)
- Removed@babel/code-frame@7.0.0-beta.34(transitive)
- Removed@babel/core@7.0.0-beta.34(transitive)
- Removed@babel/generator@7.0.0-beta.34(transitive)
- Removed@babel/helper-annotate-as-pure@7.0.0-beta.34(transitive)
- Removed@babel/helper-define-map@7.0.0-beta.34(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.34(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.34(transitive)
- Removed@babel/helper-optimise-call-expression@7.0.0-beta.34(transitive)
- Removed@babel/helper-replace-supers@7.0.0-beta.34(transitive)
- Removed@babel/helpers@7.0.0-beta.34(transitive)
- Removed@babel/template@7.0.0-beta.34(transitive)
- Removed@babel/traverse@7.0.0-beta.34(transitive)
- Removed@babel/types@7.0.0-beta.34(transitive)
- Removedbabylon@7.0.0-beta.34(transitive)