Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/plugin-transform-classes

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-classes - npm Package Compare versions

Comparing version 7.0.0-beta.34 to 7.0.0-beta.35

46

lib/vanilla.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc