Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function extractElementDescriptor(/* this: File, */ classRef, superRef, path) {
const { node, scope } = path;
const isMethod = path.isClassMethod();
if (path.isPrivate()) {
throw path.buildCodeFrameError(
`Private ${
isMethod ? "methods" : "fields"
} in decorated classes are not supported yet.`,
);
}
new ReplaceSupers(
{
methodPath: path,
methodNode: node,
objectRef: classRef,
isStatic: node.static,
superRef,
scope,
file: this,
},
true,
).replace();
const properties = [
prop("kind", t.stringLiteral(isMethod ? node.kind : "field")),
prop("decorators", takeDecorators(node)),
prop("static", node.static && t.booleanLiteral(true)),
const findBareSupers = _core.traverse.visitors.merge([{
Super(path) {
const {
node,
parentPath
} = path;
if (parentPath.isCallExpression({
callee: node
})) {
this.push(parentPath);
}
}
}, _helperReplaceSupers.environmentVisitor]);
const referenceVisitor = {
"TSTypeAnnotation|TypeAnnotation"(path) {
path.skip();
},
ReferencedIdentifier(path) {
if (this.scope.hasOwnBinding(path.node.name)) {
this.scope.rename(path.node.name);
path.skip();
}
}
};
function handleClassTDZ(path, state) {
function getSingleElementDefinition(path, superRef, classRef, file) {
const { node, scope } = path;
const isMethod = path.isClassMethod();
if (path.isPrivate()) {
throw path.buildCodeFrameError(
`Private ${
isMethod ? "methods" : "fields"
} in decorated classes are not supported yet.`,
);
}
new ReplaceSupers(
{
methodPath: path,
methodNode: node,
objectRef: classRef,
isStatic: node.static,
superRef,
scope,
file,
},
true,
).replace();
const properties = [
prop("kind", t.stringLiteral(isMethod ? node.kind : "field")),
prop("decorators", takeDecorators(path)),
prop("static", node.static && t.booleanLiteral(true)),
const node = path.node;
if (path.isClassProperty()) {
throw path.buildCodeFrameError("Missing class properties transform.");
}
if (node.decorators) {
throw path.buildCodeFrameError(
"Method has decorators, put the decorator plugin before the classes one.",
);
}
if (t.isClassMethod(node)) {
const isConstructor = node.kind === "constructor";
const replaceSupers = new ReplaceSupers({
methodPath: path,
objectRef: classState.classRef,
superRef: classState.superName,
isLoose: classState.isLoose,
file: classState.file,
});
replaceSupers.replace();
const superReturns = [];
path.traverse(
traverse.visitors.merge([
environmentVisitor,
{
ReturnStatement(path) {
if (!path.getFunctionParent().isArrowFunctionExpression()) {
function replaceThisContext(path, ref, superRef, file, loose) {
const state = { classRef: ref, needsClassRef: false };
const replacer = new ReplaceSupers({
methodPath: path,
isLoose: loose,
superRef,
file,
getObjectRef() {
state.needsClassRef = true;
return path.node.static
? ref
: t.memberExpression(ref, t.identifier("prototype"));
},
});
replacer.replace();
if (path.isProperty()) {
path.traverse(thisContextVisitor, state);
}
return state.needsClassRef;
function replacePropertySuper(path, node, scope, getObjectRef, file) {
const replaceSupers = new ReplaceSupers({
getObjectRef: getObjectRef,
methodNode: node,
methodPath: path,
isStatic: true,
scope: scope,
file: file,
});
replaceSupers.replace();
}
function replacePropertySuper(path, getObjectRef, file) {
const replaceSupers = new ReplaceSupers({
getObjectRef: getObjectRef,
methodPath: path,
file: file,
});
replaceSupers.replace();
}