Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module augmentation is not working in .vue file

there is a module augmentation (types/test.d.ts):

import Vue from 'vue'

declare module 'vue/types/vue' {
  interface Vue {
    $test: string
  }
}

And include it as (tsconfig.json):

// ...
"include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx",
    "types/*.d.ts"
  ],
// ...

And then, it works fine in any .ts file:

enter image description here enter image description here

But it just gets a compile error in .vue file enter image description here

Could anyone help me?

like image 485
BabyCabbage Avatar asked Oct 09 '19 05:10

BabyCabbage


1 Answers

Try to add types/*.d.ts to typeRoots in yout tsconfig

Like this:

"typeRoots": [
        "src/types"
    ],

(Normally I use @types to store my .d.ts files)

like image 128
Paolo Donato Navarro Avatar answered Oct 24 '22 12:10

Paolo Donato Navarro