環境
vscode 1.82.2
vue 3.3.4
typescript 5.1.6
vite 4.4.9
v-calendar 3.0.3
手順
1.以下からnpmでインストール
VCalendar
npm install v-calendar@next @popperjs/core
2.main.tsで使用するコンポーネントをimport
main.ts
import { Calendar, DatePicker } from 'v-calendar';
...
app.component('Calendar', Calendar)
app.component('DatePicker', DatePicker)
現象
以下のエラーが発生。
モジュール 'v-calendar' の宣言ファイルが見つかりませんでした。'.../index.jsは暗黙的に 'any' 型になります。
There are types at '.../index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'v-calendar' library may need to update its package.json or typings.ts(7016)
原因
型定義ファイル(d.ts)がないことが原因だった。
対策
作業ディレクトリに定義ファイルである@types/v-calendarを追加。
v-calendar.d.ts
declare module 'v-calendar'
・その他試したこと(失敗)
npmで@types/v-calendarをインストール。
用意されていませんでした。
npm install @types/v-calendar
参考サイト