Last active
December 8, 2018 15:45
-
-
Save yutahaga/bbf4f632f68df135082b29b5b99f7f89 to your computer and use it in GitHub Desktop.
@nuxtjs/apollo 用の Vue 拡張宣言ファイル。
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
/** | |
* Extends interfaces in Vue.js | |
*/ | |
import ApolloClient from 'apollo-client' | |
import { AxiosInstance } from 'axios' | |
import Vue, { ComponentOptions } from 'vue' | |
import { VueApollo } from 'vue-apollo/types/vue-apollo' | |
import { Route } from 'vue-router' | |
import { MetaInfo } from 'vue-meta' | |
// 公式 dev ブランチの index.d.ts を nuxt.d.ts として配置。 | |
// 使ってるバージョンに型ファイル追加されたら from 'nuxt' で OK ! | |
import { Context, Transition, LoadingObject } from './nuxt' | |
declare module 'vue/types/options' { | |
interface ComponentOptions<V extends Vue> { | |
asyncData?(ctx: Context): object | undefined | |
fetch?(ctx: Context): Promise<void> | void | |
head?: MetaInfo | (() => MetaInfo) | |
key?: string | ((to: Route) => string) | |
layout?: string | ((ctx: Context) => string) | |
middleware?: string | string[] | |
scrollToTop?: boolean | |
transition?: string | Transition | ((to: Route, from: Route) => string) | |
validate?(ctx: Context): Promise<boolean> | boolean | |
watchQuery?: boolean | string[] | |
} | |
} | |
declare module 'vue/types/vue' { | |
interface apolloHelpers { | |
onLogin<R = any>( | |
token: string, | |
apolloClient?: ApolloClient<R>, | |
tokenExpires?: number | |
): Promise<void> | |
onLogout<R = any>(apolloClient?: ApolloClient<R>): Promise<void> | |
getToken(tokenName: string): boolean | string | |
} | |
interface Vue { | |
apolloProvider: VueApollo | |
$apolloHelpers: apolloHelpers | |
$axios: AxiosInstance | |
$nuxt: { | |
$loading: LoadingObject | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment