找不到模块 'vue2-timepicker' 的声明文件

Could not find a declaration file for module 'vue2-timepicker'

夏天

我在 Typescript/Nuxt.js 应用程序中添加了 vue2-timepicker
但是导入失败 vue2-timepicker

import timepicker from 'vue2-timepicker'
Could not find a declaration file for module 'vue2-timepicker'.
'/home/jpskgc/sample-nuxt/node_modules/vue2-timepicker/dist/VueTimepicker.umd.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/vue2-timepicker` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue2-timepicker';`

我想解决这个问题。

描述一下我的尝试。

我尝试添加@types/vue2-timepicker,但它不存在。

❯ yarn add @types/vue2-timepicker
yarn add v1.22.17
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@types%2fvue2-timepicke: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/home/jpskgc/sample-nuxt/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

显示一些代码。

这是实际的存储库。请检查。
https://github.com/jpskgc/nuxt-sample/blob/main/components/registration-form/index.vue

由于包的类型不可用,请尝试忽略它们。

// @ts-ignore

导入的包可以正常工作。

其他选项是创建虚拟 .d.ts 定义,这将允许从模块中导入任何内容。