Vue-apollo: Types not available for use in Typescript project

Created on 13 Apr 2017  路  3Comments  路  Source: vuejs/vue-apollo

It would be great if you could add types of using this plugin in typescript project. Otherwise could you tell how to write custom types for bypass type checks?

I tried adding this to a type definition file but it didn't work -

/**
 * Augment the typings of Vue.js
 */

declare module 'vue/types/vue' {
  import Vue from 'vue';
  export interface Vue {
    $apollo: any;
  }
}

declare module 'vue/types/options' {
  import Vue from 'vue';
  export interface ComponentOptions<V extends Vue> {
    apollo?: any;
  }
}
enhancement help wanted

Most helpful comment

For your question, you're right, here it is :

import Vue from 'vue';
declare module "vue/types/vue" {
  interface Vue {
    $apollo: any;
  }
}

declare module 'vue/types/options' {
  interface ComponentOptions<V extends Vue> {
    apollo?: any;
  }
}

All 3 comments

View itself has typescript definitions but vue-apollo, no.

So here's a stating point for vue-apollo :

declare module "vue-apollo" {
  import { ApolloClient } from 'apollo-client';
  import Vue, { PluginObject } from 'vue';

  export const addGraphQLSubscriptions: {};

  class VueApollo implements PluginObject<{}> {
    [key: string]: any;
    install: PluginFunction<{}>;
    constructor (options: {defaultClient: ApolloClient});
    static install(pVue: typeof Vue, options?:{} | undefined): void;
  }
  export default VueApollo;
}

For your question, you're right, here it is :

import Vue from 'vue';
declare module "vue/types/vue" {
  interface Vue {
    $apollo: any;
  }
}

declare module 'vue/types/options' {
  interface ComponentOptions<V extends Vue> {
    apollo?: any;
  }
}

Hi,
The proposed solution by @stphdenis doesn't work for me.
Has someone figured it out?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ais-one picture ais-one  路  4Comments

danthareja picture danthareja  路  4Comments

ScreamZ picture ScreamZ  路  4Comments

Akryum picture Akryum  路  3Comments

apertureless picture apertureless  路  4Comments