If you open this file in VSCode ...
/* global somePromise */
async function foo() {
const { baz } = this;
await somePromise;
console.log(baz, this.bar);
}
await foo();
You'll see a red-squiggly on the this.bar
text. Activating the "Replace this.bar
with destructured bar
" quick fix will hoist bar
into the destructuring statement, giving you this:
/* global somePromise */
async function foo() {
const {baz, bar} = this;
await somePromise;
console.log(baz, bar);
}
await foo();
The problem with modified code is that bar's value is not guaranteed to be the same pre-await as it is post-await. (E.g. if somePromise
is responsible for initializing this.bar
, then bar
will hold the uninitialized value.)
It's good that this doesn't happen automatically on --fix
, but this suggestion should either be disabled in this case, or include some sort of warning to the user.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too