Skip to content

Convert to Async not working if I have a "catch" statement #31897

@johnpapa

Description

@johnpapa
  • VSCode Version: Version 1.36.0-insider (1.36.0-insider)
  • OS Version: macOS Mohave 10.14.5 (18F132)

Steps to Reproduce:

  1. write a javascript function that returns a promise
  2. try quick fix to convert to async (it works)
  3. add a catch statement
  4. try quick fix to convert to asynx (it is not offered)

This code works ...

    updateHeroAction({ commit }, hero) {
      return axios.put(`${API}/heroes/${hero.id}`, hero).then(response => {
        const updatedHero = parseItem(response, 200);
        commit(UPDATE_HERO, updatedHero);
        return updatedHero;
      });
    },

Now add a catch, and there is not quick fix offered

    updateHeroAction({ commit }, hero) {
      return axios
        .put(`${API}/heroes/${hero.id}`, hero)
        .then(response => {
          const updatedHero = parseItem(response, 200);
          commit(UPDATE_HERO, updatedHero);
          return updatedHero;
        })
        .catch(captains.error);
    },

See this GIF for details ...
2019-06-11_07-39-07-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions