vuetify: [Bug Report] Could not find a declaration file for module 'vuetify/lib'
Versions and Environment
Vuetify: 1.3.15 Vue: 2.5.17 Browsers: Google Chrome OS: Windows 10
Steps to reproduce
Hi guys, I follow the Vue-CLI 3 guide and when I try to compile the source code the terminal show me a Typescript error.
$ vue create my-app
$ cd my-app
$ vue add vuetify
$ npm run serve
Expected Behavior
The Typescript code should compile.
Actual Behavior
2:21 Could not find a declaration file for module 'vuetify/lib'. 'C:/project/path/node_modules/vuetify/lib/index.js' implicitly has an 'any' type.
Try `npm install @types/vuetify` if it exists or add a new declaration (.d.ts) file containing `declare module 'vuetify/lib';`
1 | import Vue from 'vue'
> 2 | import Vuetify from 'vuetify/lib'
| ^
3 | import 'vuetify/src/stylus/app.styl'
4 |
5 | Vue.use(Vuetify, {
Reproduction Link
https://codepen.io/MatiasOlivera/pen/JwbQqy
Other comments
Typescript: 3.2.2
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 62
- Comments: 19 (3 by maintainers)
Commits related to this issue
- fix typescript compiler error https://github.com/vuetifyjs/vuetify/issues/5944 — committed to ferrywlto/vuetify-pwa-starter by ferrywlto 5 years ago
- Fixed error 'vuetify' does not exist in type https://github.com/vuetifyjs/vuetify/issues/5944 https://github.com/vuetifyjs/vuetify/issues/8289 — committed to frank-yoon/vue-cloud by frank-yoon 4 years ago
- vuetify had a missing type declaration in tsconfig, as desribed here: https://github.com/vuetifyjs/vuetify/issues/5944#issuecomment-480494060 modified: tsconfig.json — committed to googleinterns/recomator by s17k 4 years ago
@KaelWD Thank you for the link. More specifically, this comment helped me out to properly update my tsconfig.json:
In our projects, we use
vue add vuetifyapproach to add Vuetify into our project.The generated file
plugins/vuetify.tshas this line:import Vuetify from 'vuetify/lib';remove the
/libfrom toimport Vuetify from 'vuetify';it will solve the issue. 🥂
if you are looking for a-la-carte installation please read: this
Adding this module declaration to a
*.d.tsfile works like a charm for my purposes:I had similar errors on a fresh install.
Once I did this, it worked.
Go in src/main.ts and paste the following content right after the imports import Vuetify from ‘vuetify’; import ‘vuetify/dist/vuetify.min.css’; Vue.use(Vuetify);
https://medium.com/@attiewilly/how-i-married-vuetify-with-typescript-d6441dedd16
This is still an issue with a brand new project created with vue cli 4 and then adding vuetify via
vue add vuetify. We shouldn’t have to be manually fixing issues after using the CLI, it should just work.This is not a good solution for two reasons:
tsconfig.json.The recommended solution is to have the declaration files output alongside the built JavaScript files. Can this please be done?
Edit: Correction to point
#1above – you only need to list packages with global declarations.Still an issue with new projects… Why is this closed?
This is added in the FAQ section of the docs.
This is really annoying, none of the above solutions works for me. New project with newest dependencies set up with CLI 3.
If i do
the error disappears but styles are missing fonts.
did not work either,
SOLUTION:
BUT this did the trick (in my tsconfig.json) , add “vuetify” to types: (And i assume its the only correct way??)
“types”: [ “webpack-env”, “jest”, “vuetify” ],
Hello guys, any news on this ?? I’d really love for vuetify to support typescript. Otherwise the tests don’t even run, so the app becomes impossible to test
@devpixde “vuetify” should be in the types anyway, but that is not what helped me out.
I’ve changed the import statement to
import { Scroll } from 'vuetify/es5/directives';and this works for me.Btw, the problem has been confirmed on official discord #bugs channel on 09/09/2019, but I’ve no idea if that yielded anything further.
@ferrywlto thanks! I’ve just used everything brand new including Vuetify 2.0.10, and stumbled upon this issue.
See https://github.com/vuetifyjs/vue-cli-plugin-vuetify/issues/43