@babel/plugin-transform-classes
Advanced tools
Comparing version 7.2.2 to 7.3.3
@@ -83,21 +83,2 @@ "use strict"; | ||
} | ||
}, | ||
ThisExpression(path, state) { | ||
if (!state.isDerived) return; | ||
const { | ||
node, | ||
parentPath | ||
} = path; | ||
if (parentPath.isMemberExpression({ | ||
object: node | ||
})) { | ||
return; | ||
} | ||
const assertion = _core().types.callExpression(state.file.addHelper("assertThisInitialized"), [node]); | ||
path.replaceWith(assertion); | ||
path.skip(); | ||
} | ||
@@ -129,3 +110,2 @@ | ||
body: [], | ||
bareSupers: new Set(), | ||
superThises: [], | ||
@@ -258,30 +238,14 @@ pushedConstructor: false, | ||
replaceSupers.replace(); | ||
const state = { | ||
returns: [], | ||
bareSupers: new Set() | ||
}; | ||
const superReturns = []; | ||
path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, { | ||
ReturnStatement(path, state) { | ||
ReturnStatement(path) { | ||
if (!path.getFunctionParent().isArrowFunctionExpression()) { | ||
state.returns.push(path); | ||
superReturns.push(path); | ||
} | ||
}, | ||
Super(path, state) { | ||
const { | ||
node, | ||
parentPath | ||
} = path; | ||
if (parentPath.isCallExpression({ | ||
callee: node | ||
})) { | ||
state.bareSupers.add(parentPath); | ||
} | ||
} | ||
}]), state); | ||
}])); | ||
if (isConstructor) { | ||
pushConstructor(state, node, path); | ||
pushConstructor(superReturns, node, path); | ||
} else { | ||
@@ -382,3 +346,2 @@ pushMethod(node, path); | ||
path.traverse(findThisesVisitor); | ||
let guaranteedSuperBeforeFinish = !!classState.bareSupers.size; | ||
@@ -393,3 +356,37 @@ let thisRef = function () { | ||
for (const bareSuper of classState.bareSupers) { | ||
for (const thisPath of classState.superThises) { | ||
const { | ||
node, | ||
parentPath | ||
} = thisPath; | ||
if (parentPath.isMemberExpression({ | ||
object: node | ||
})) { | ||
thisPath.replaceWith(thisRef()); | ||
continue; | ||
} | ||
thisPath.replaceWith(_core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()])); | ||
} | ||
const bareSupers = new Set(); | ||
path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, { | ||
Super(path) { | ||
const { | ||
node, | ||
parentPath | ||
} = path; | ||
if (parentPath.isCallExpression({ | ||
callee: node | ||
})) { | ||
bareSupers.add(parentPath); | ||
} | ||
} | ||
}])); | ||
let guaranteedSuperBeforeFinish = !!bareSupers.size; | ||
for (const bareSuper of bareSupers) { | ||
wrapSuperCall(bareSuper, classState.superName, thisRef, body); | ||
@@ -411,18 +408,2 @@ | ||
for (const thisPath of classState.superThises) { | ||
const { | ||
node, | ||
parentPath | ||
} = thisPath; | ||
if (parentPath.isMemberExpression({ | ||
object: node | ||
})) { | ||
thisPath.replaceWith(thisRef()); | ||
continue; | ||
} | ||
thisPath.replaceWith(_core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()])); | ||
} | ||
let wrapReturn; | ||
@@ -513,3 +494,3 @@ | ||
function pushConstructor(replaceSupers, method, path) { | ||
function pushConstructor(superReturns, method, path) { | ||
if (path.scope.hasOwnBinding(classState.classRef.name)) { | ||
@@ -523,4 +504,3 @@ path.scope.rename(classState.classRef.name); | ||
hasConstructor: true, | ||
bareSupers: replaceSupers.bareSupers, | ||
superReturns: replaceSupers.returns | ||
superReturns | ||
}); | ||
@@ -527,0 +507,0 @@ const { |
{ | ||
"name": "@babel/plugin-transform-classes", | ||
"version": "7.2.2", | ||
"version": "7.3.3", | ||
"description": "Compile ES2015 classes to ES5", | ||
@@ -28,5 +28,6 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/core": "^7.3.3", | ||
"@babel/helper-plugin-test-runner": "^7.0.0" | ||
} | ||
}, | ||
"gitHead": "d1fe2d05f4c468640facf40565e30f7110757f2d" | ||
} |
Sorry, the diff of this file is not supported yet
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
24023
591