Vue-cli: Typescript doesn't recognise plugins

Created on 24 Jun 2018  路  3Comments  路  Source: vuejs/vue-cli

Version

3.0.0-rc.3

Reproduction link

https://github.com/eladcandroid/vue-cli-errors

Steps to reproduce

Create a new project with typescript and linter support
Install axios plugin with "vue ui"
Try to use this.$axios in HelloWorld.vue

What is expected?

No errors

What is actually happening?

Got a lint error - Property '$axios' does not exist on type 'HelloWorld'
(Less important but also got warning errors about semi-colons)

Most helpful comment

@eladcandroid You've probably already solved this but for anyone else who stumbles across this issue you may need to add this shim to get Axios types against this.$axios.

import axios from 'axios';

declare module 'vue/types/vue' {
  interface Vue {
    $axios: typeof axios
  }
}

All 3 comments

That's an issue in the axios plugin, which isn't maintained by us. It needs to account for type shims when used with typescript.

@eladcandroid You've probably already solved this but for anyone else who stumbles across this issue you may need to add this shim to get Axios types against this.$axios.

import axios from 'axios';

declare module 'vue/types/vue' {
  interface Vue {
    $axios: typeof axios
  }
}

@Robula do you know how to do it for Store?

Property '$axios' does not exist on type 'Store<any>'

Was this page helpful?
0 / 5 - 0 ratings