0

I have this code, Vue 3 + Vite:

<script setup>
import { computed, onMounted } from "vue";
import { useStore } from "vuex";

const store = useStore();

const playlists = computed(() => store.getters["playlists/allPlaylists"]);
const playlistsCount = computed(
  () => store.getters["playlists/allPlaylistsCount"]
);
const selectPlaylist = (playlist) => {
  store.dispatch("playlists/selectPlaylist", playlist);
}

onMounted(async () => { await store.dispatch('playlists/getAllPlaylists') })
</script>

I'm not using typescript, I use Visual Studio Code.

I get warned by the IDE on the onMounted method with:

An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.ts(2705)

my jsconfig.json

{
  "include": [
    "./src/**/*"
  ],
  "compilerOptions": {
    "checkJs": true,
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "src/*"
      ]
    }
  }
}

anything I can do to make the IDE error go away?

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
John Smith
  • 1,726
  • 2
  • 18
  • 30
  • 2
    You're not using TS but VSC does. You're certainly not using ES5 because of Vite, so it needs to be adjusted the other way, `target: "esnext"` in compilerOptions – Estus Flask Aug 21 '21 at 14:43
  • 1
    Does this answer your question? [ts An async function or method in ES5/ES3 requires the 'Promise' constructor](https://stackoverflow.com/questions/43555378/ts-an-async-function-or-method-in-es5-es3-requires-the-promise-constructor) – futur Aug 21 '21 at 14:57

0 Answers0