Created
August 14, 2018 11:12
-
-
Save stepbeekio/1d5392b13503dca248556f0457e83ffd to your computer and use it in GitHub Desktop.
Typescript working with asyncData & fetch for Nuxt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import { Store } from 'vuex' | |
// ComponentOptions is declared in types/options.d.ts | |
declare module 'vue/types/options' { | |
interface NuxtContext<V extends Vue> { | |
app: V, | |
isClient: boolean, | |
isServer: boolean, | |
isStatic: boolean, | |
isDev: boolean, | |
store: Store<any>, // Consider vuex-typex in future | |
env: object, | |
params: object, | |
query: object | |
} | |
interface ComponentOptions<V extends Vue> { | |
asyncData?(context: NuxtContext<V>): Promise<object> | object | |
fetch?(context: NuxtContext<V>): Promise<object> | object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment