Typescript: Property $axios does not exist on type 'CombinedVueInstance plugin nuxt

Created on 10 Apr 2020  路  5Comments  路  Source: nuxt/typescript

Version

v2.12.2

Reproduction link

https://github.com/YLT-PROJECT/nuxt-project

Steps to reproduce

  1. Clone repository of reproduction link
  2. Run npm install for installing dependencies
  3. Open Login component and at the login method try to access to $axios property

What is expected ?

What is expected is that the editor suggests me the methods of AxiosInstance

What is actually happening?

The VSCode typescript compiler points me that $axios not exists

Additional comments?

I am begining to use typescript in my projects for more ease, but I got stacked always on errors like I comment on this issue
I don't know how can I use .d.ts files to add properties to Vue Components, this could solve me the problem

Please, help :)

This bug report is available on Nuxt community (#c10506)

Most helpful comment

Hey @contrerascoder , you need to add "@nuxtjs/axios" to the types array here : https://github.com/YLT-PROJECT/nuxt-project/blob/master/tsconfig.json#L28 :)

Then ensure you restart editor after this change :)

All 5 comments

Hey @contrerascoder , you need to add "@nuxtjs/axios" to the types array here : https://github.com/YLT-PROJECT/nuxt-project/blob/master/tsconfig.json#L28 :)

Then ensure you restart editor after this change :)

Small remark: this is not automatically configured if you have TS and Axios selected in the create-nuxt-app.

@lextoc see my PR here: https://github.com/nuxt/create-nuxt-app/pull/449

It's been delayed a long time, throw a +1 on it!

Im my case, I was missing to use Vue.extend({}) or Vue.Component as described here https://vuejs.org/v2/guide/typescript.html#Basic-Usage and here https://typescript.nuxtjs.org/

Was this page helpful?
0 / 5 - 0 ratings