LoginSignup
4
2

More than 3 years have passed since last update.

vue-good-tableをTypeScriptで使おうとして TS7016: Could not find a declaration file for module 'vue-good-table'.

Posted at

使用バージョン

$ npm list vue typescript vue-good-table
app@1.0.0
├── typescript@3.8.3
├── vue@2.6.11
└── vue-good-table@2.19.1

問題

Vue.jsをTypeScriptで使っていて、以下ドキュメントどおりに進めたところ、コンパイルエラー発生。

https://xaksis.github.io/vue-good-table/guide/#installation

エラー内容


TS7016: Could not find a declaration file for module 'vue-good-table'. 
'[app]/node_modules/vue-good-table/dist/vue-good-table.cjs.js'
implicitly has an 'any' type.

解決

[app]/@types/以下にファイル作成。

vue-good-table.d.ts

declare module 'vue-good-table'

TypeScriptまだ良く分からないですが、moduleを宣言すれば良いらしい。
@types/に関しては、d.tsファイルをそこに置くとコンパイル時に読み込んでくれるよう。

※ tsconfig.json の typeRoots のデフォルト設定が @types ディレクトリになっています。
https://qiita.com/Nossa/items/726cc3e67527e896ed1e

VueGoodTableはanyだけど、とりあえずコンパイルはできました!

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2