Import d.ts definitions from specific node_modules package

452 Views Asked by At

I have vue2 + vuetify + typescript starter app. It has shims-vuetify.d.ts file with the following content:

declare module 'vuetify/lib/framework' {
  import Vuetify from 'vuetify'
  export default Vuetify
}

Then it's imported in /plugins/vuetify.ts file like that:

import Vue from 'vue'
import Vuetify from 'vuetify/lib/framework'

Vue.use(Vuetify)

export default new Vuetify({
})

It works just fine.

My goal is to extend some vuetify component in typescript. For that I'm importing the typescript source code from vuetify/src/ (not the js-code from vuetify/lib):

import VAutocomplete from 'vuetify/src/components/VAutocomplete'

export default VAutocomplete.extend({
  ...my stuff..
}) 

It works, but typescript throws a lot of errors during compilation.

It does not see the node_modules/vuetify/src/globals.d.ts file.

The question is: how to point typescript to use this declaration file?

I guess the right way is to create shims-vuetify-src.d.ts file and refer to globals.d.ts there somehow, but for now I was not able to do that correctly.

0

There are 0 best solutions below