-
-
Save iwata/7b487a4bd2323a201726d320c8839efa to your computer and use it in GitHub Desktop.
Nuxt.jsで必要なTypeScriptの型定義
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' | |
import VueRouter, {Route} from 'vue-router' | |
import {MetaInfo} from 'vue-meta' | |
import {Snackbar, Toast} from 'buefy' | |
interface ErrorParams { | |
statusCode?: string | |
message?: string | |
} | |
// Ref. https://nuxtjs.org/api/context | |
interface NuxtContext { | |
app: Vue | |
isStatic: boolean | |
isDev: boolean | |
isHMR: boolean | |
route: Route | |
store: Store<any> | |
env: object | |
query: Route['query'] | |
nuxtState: object | |
req: Request | |
res: Response | |
params: Route['params'] | |
redirect(path: string, query?: Route['query']): void | |
redirect(status: number, path: string, query?: Route['query']): void | |
error(params: ErrorParams): void | |
beforeNuxtRender({Conmponents, nuxtState}: any): void | |
} | |
declare module 'vue/types/options' { | |
interface ComponentOptions<V extends Vue> { | |
layout?: string | |
middleware?: string | String[] | |
scrollToTop?: boolean | |
transition?: string | object | Function | |
head?(): MetaInfo | |
fetch?(context: NuxtContext): void | |
asyncData?(context: NuxtContext): void | |
validate?(context: NuxtContext): boolean | |
} | |
} | |
declare module 'vue/types/vue' { | |
interface Vue { | |
$router: VueRouter | |
$route: Route | |
$snackbar: typeof Snackbar | |
$toast: typeof Toast | |
$copyText(text: string, container?: any): Promise<Event> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment