Issue
Summery
I added vue2-timepicker in my Typescript/Nuxt.js application.
But it is failed to import 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';`
I want to resolve this problem.
Describe what I've tried.
I tried to add @types/vue2-timepicker, but it does not exist.
❯ 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.
Show some codes.
Here is the actual repository. Please check.
https://github.com/jpskgc/nuxt-sample/blob/main/components/registration-form/index.vue
Solution
As the types for the package are not available try ignoring them.
// @ts-ignore
The imported package would work just fine.
Other options would be to create dummy .d.ts
definition which will allow to import anything from the module.
Answered By - tejastn10
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.