codemod
codemod copied to clipboard
Async codemod introduces improper awaits and does not create async anonymous function contexts
Running the async codemod on the following code
const foo = function() {
mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};
produces
const foo = function() {
await mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};
This is syntactically incorrect for two reasons.
- The outer function context
foois notasyncso it doesn't make sense to useawaitwithin it. - The function called in the inner scope
mySyncFunctionDoesNotReturnAPromiseOrEvenExistdoes not return a Promise, so it doesn't make sense to useawait.