iwpnd logo

Typescript destructuring re-assignment

Destructuring needs to be either after a let, const or var declaration OR it needs to be in an expression context to distinguish it from a block statement.

let variable: number

if (true) {
	({ bla: variable } = someFunction());
} else {
	({ bla: variable } = someOtherFunction());
}
· til, typescript