const calllback = event=> {
let {target} = event;
// code with used target
}
to
const calllback = ({target})=> {
// code with used target
}
Same in the opposite direction and with a more complex and deep destructure and function content.
But shouldn't it be event.target?
const calllback = event => {
const target = event.target;
// code with used target
}
to
const calllback = ({target}) => {
// code with used target
}
@Shinigami92 Of course (May optionally be const {target} = event).
Sorry for the mistake.
There's a big difference between your two examples though. In the first one target is a constant, but not in the second one. Destructured variables in function parameters can be reassigned.
@jcready Oh, I do not know why it seemed to me that it was different.
This somewhat limits this proposed refactoring function. : |
Actually, you can do it somehow? Or are there any standard plans for this?
Hi folks.
There's a similar refactor https://github.com/microsoft/TypeScript/pull/39832 that do not convert at the original position but append new line below
@Kingwl What about function parameter destructure? And it looks like it works in one direction.
Well, It's good to take a try.
Most helpful comment
@Shinigami92 Of course (May optionally be
const {target} = event).Sorry for the mistake.