feat: WIP assignements
This commit is contained in:
parent
6bd3bf4d2f
commit
cc6959e1fa
@ -37,27 +37,37 @@ export default function ({ types: t }) {
|
||||
path.scope.push({ id });
|
||||
}
|
||||
|
||||
let remplacement;
|
||||
if (t.isAssignmentExpression(path.parent)) {
|
||||
|
||||
if (t.isCallExpression(path.parent)) {
|
||||
const remplacement = createCondition(
|
||||
t.identifier("temp_here_please"),
|
||||
object,
|
||||
property,
|
||||
t.identifier("undefined"),
|
||||
);
|
||||
|
||||
remplacement = createCondition(
|
||||
path.parentPath.replaceWith(remplacement);
|
||||
} else if (t.isCallExpression(path.parent)) {
|
||||
|
||||
const remplacement = createCondition(
|
||||
state.optionalTemp,
|
||||
object,
|
||||
property,
|
||||
t.callExpression(t.identifier("Function"), [])
|
||||
t.callExpression(t.identifier("Function"), []),
|
||||
);
|
||||
|
||||
path.replaceWith(remplacement);
|
||||
} else {
|
||||
|
||||
remplacement = createCondition(
|
||||
const remplacement = createCondition(
|
||||
state.optionalTemp,
|
||||
object,
|
||||
property,
|
||||
t.identifier("undefined")
|
||||
t.identifier("undefined"),
|
||||
);
|
||||
}
|
||||
|
||||
path.replaceWith(remplacement);
|
||||
path.replaceWith(remplacement);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -0,0 +1 @@
|
||||
a?.b = 42
|
||||
Loading…
x
Reference in New Issue
Block a user