Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
call = t.callExpression(
classState.file.addHelper("possibleConstructorReturn"),
[t.thisExpression(), bareSuperNode],
);
}
if (
bareSuper.parentPath.isExpressionStatement() &&
bareSuper.parentPath.container === body.node.body &&
body.node.body.length - 1 === bareSuper.parentPath.key
) {
// this super call is the last statement in the body so we can just straight up
// turn it into a return
if (classState.superThises.length) {
call = t.assignmentExpression("=", thisRef(), call);
}
bareSuper.parentPath.replaceWith(t.returnStatement(call));
} else {
bareSuper.replaceWith(t.assignmentExpression("=", thisRef(), call));
}
}
argument,
callExpression,
] = createObjectSpread(leftPath, file, t.identifier(refName));
if (impureComputedPropertyDeclarators.length > 0) {
nodes.push(
t.variableDeclaration("var", impureComputedPropertyDeclarators),
);
}
const nodeWithoutSpread = t.cloneNode(path.node);
nodeWithoutSpread.right = t.identifier(refName);
nodes.push(t.expressionStatement(nodeWithoutSpread));
nodes.push(
t.toStatement(
t.assignmentExpression("=", argument, callExpression),
),
);
nodes.push(t.expressionStatement(t.identifier(refName)));
path.replaceWithMultiple(nodes);
}
},
// taken from transform-destructuring/src/index.js#visitor
function buildPublicFieldInitLoose(ref, prop) {
const { key, computed } = prop.node;
const value = prop.node.value || prop.scope.buildUndefinedNode();
return t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(ref, key, computed || t.isLiteral(key)),
value,
),
);
}
state.returnStatements.forEach(returnStatement => {
returnStatement.insertBefore(
t.expressionStatement(
t.assignmentExpression(
"=",
t.identifier(paramName),
t.identifier(newParamName),
),
),
);
});
buildVariableAssignment(id, init) {
let op = this.operator;
if (t.isMemberExpression(id)) op = "=";
let node;
if (op) {
node = t.expressionStatement(
t.assignmentExpression(
op,
id,
t.cloneNode(init) || this.scope.buildUndefinedNode(),
),
);
} else {
node = t.variableDeclaration(this.kind, [
t.variableDeclarator(id, t.cloneNode(init)),
]);
}
node._blockHoist = this.blockHoist;
return node;
}
ObjectExpression(path, state) {
let objectRef;
const getObjectRef = () =>
(objectRef = objectRef || path.scope.generateUidIdentifier("obj"));
path.get("properties").forEach(propPath => {
if (!propPath.isMethod()) return;
replacePropertySuper(propPath, getObjectRef, state);
});
if (objectRef) {
path.scope.push({ id: t.cloneNode(objectRef) });
path.replaceWith(
t.assignmentExpression("=", t.cloneNode(objectRef), path.node),
);
}
},
},
node.generator,
node.async,
);
t.inherits(func, node);
const key = t.toComputedKey(node, node.key);
if (t.isStringLiteral(key)) {
func = nameFunction({
node: func,
id: key,
scope,
});
}
const expr = t.expressionStatement(
t.assignmentExpression("=", methodName, func),
);
t.inheritsComments(expr, node);
classState.body.push(expr);
return true;
}
return false;
}
modules.forEach(function(specifiers) {
let setterBody = [];
const target = path.scope.generateUid(specifiers.key);
for (let specifier of specifiers.imports) {
if (t.isImportNamespaceSpecifier(specifier)) {
setterBody.push(
t.expressionStatement(
t.assignmentExpression(
"=",
specifier.local,
t.identifier(target),
),
),
);
} else if (t.isImportDefaultSpecifier(specifier)) {
specifier = t.importSpecifier(
specifier.local,
t.identifier("default"),
);
}
if (t.isImportSpecifier(specifier)) {
setterBody.push(
t.expressionStatement(
function pushMutatorDefine({ body, getMutatorId, scope }, prop) {
let key =
!prop.computed && t.isIdentifier(prop.key)
? t.stringLiteral(prop.key.name)
: prop.key;
const maybeMemoise = scope.maybeGenerateMemoised(key);
if (maybeMemoise) {
body.push(
t.expressionStatement(t.assignmentExpression("=", maybeMemoise, key)),
);
key = maybeMemoise;
}
body.push(
...buildMutatorMapAssign({
MUTATOR_MAP_REF: getMutatorId(),
KEY: t.cloneNode(key),
VALUE: getValue(prop),
KIND: t.identifier(prop.kind),
}),
);
}