I have the following code
const myVariable: number | undefined;
if (someCondition) {
const { someAttribute, anotherAttribute } = someFunction(); //here I want to assign directly that myVariable to someAttribute.
doAnotherTask(anotherAttribute);
}
doSomethingWithVariable(myVariable);
How can I destruct someFunction to get someAttribute and directly assign myVariable to it.
const {someAttribute: myVariable} wouldnt work here, since myVariable is defined outside the scope of the condition.