Nuxt.js fetch functionality

stepbeekio
0
stepbeekio
commented 2 years ago

What problem does this feature solve?

https://nuxtjs.org/api/pages-fetch/

I would like support for the above Nuxt.js function such that the following code works:

export default Vue.extend({
  ...

  async fetch({ store }) {
    await store.dispatch('someAction');
  }
  ...
})

Currently, this is met with a TS2345 error since the argument is not declared in the Vue.js Typescript definitions. I'm not sure if the onus is on Nuxt here, or whether the Vue.js typescript project should offer something more general?

idea
0
qm3ster
383
qm3ster
commented 2 years ago

Nuxt isn't focused on TypeScript at the moment, but it would be sensible for 'nuxt' to reexport an augmented type for pages. Very roughly like this:

import Vue from 'vue'
export interface NuxtPage extends Vue{
    newProp: any
}
0
Informations
Feature Request โ€ข Open
#c41 - Created 2 years ago