Skip to content

Incorrect "convert to async function" refactoring #27641

Closed
@mjbvz

Description

@mjbvz

From @chrfrasco on October 9, 2018 7:45

  • VSCode Version: 1.28.0
  • OS Version: macos 10.13.6

If/else is stripped out by convert to async refactor, and convert all to async does nothing

Steps to Reproduce:

  1. Convert bar to async function
function foo() {
  return Promise.resolve(Math.random())
}

function bar() {
  return foo()
    .then(num => {
      if (num > 0.5) {
        return fetch("/big")
          .then(() => 'big');
      } else {
        return fetch("/small")
          .then(() => 'small');
      }
    })
    .catch(() => -1);
}
  1. Get this
async function bar() {
  try {
    const num = await foo();
    await fetch("/big");
    return 'big';
    await fetch("/small");
    return 'small';
  }
  catch (e) {
    return -1;
  }
}
  1. convert all to async does nothing

Does this issue occur when all extensions are disabled?: Yes

Copied from original issue: microsoft/vscode#60257

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbol

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions