Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Could not find a declaration file for module 'vuetify/lib' #5944

Closed
MatiasOlivera opened this issue Dec 19, 2018 · 19 comments
Closed

Comments

@MatiasOlivera
Copy link

MatiasOlivera commented Dec 19, 2018

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

@KaelWD
Copy link
Member

KaelWD commented Dec 20, 2018

See vuetifyjs/vue-cli-plugins#43

@Al-un
Copy link

Al-un commented Apr 6, 2019

@KaelWD Thank you for the link. More specifically, this comment helped me out to properly update my tsconfig.json:

"compilerOptions": {
  "types": ["...", "vuetify"],

@glen-84
Copy link

glen-84 commented May 14, 2019

This is not a good solution for two reasons:

  1. You now have to manually list all packages with types in tsconfig.json.
  2. The package consumer should not have to do anything for bundled types to work.

The recommended solution is to have the declaration files output alongside the built JavaScript files. Can this please be done?

Edit: Correction to point #1 above – you only need to list packages with global declarations.

@hamza0867
Copy link

hamza0867 commented Aug 6, 2019

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

@timothyeash
Copy link

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

@ferrywlto
Copy link

ferrywlto commented Aug 9, 2019

In our projects, we use vue add vuetify approach to add Vuetify into our project.

The generated file plugins/vuetify.ts has this line:

import Vuetify from 'vuetify/lib';

remove the /lib from to import Vuetify from 'vuetify';

it will solve the issue. 🥂

if you are looking for a-la-carte installation please read: this

ferrywlto added a commit to ferrywlto/vuetify-pwa-starter that referenced this issue Aug 10, 2019
@Aurora12
Copy link

@ferrywlto thanks! I've just used everything brand new including Vuetify 2.0.10, and stumbled upon this issue.

@esbgo97
Copy link

esbgo97 commented Sep 17, 2019

I solved it by deleting the instance and imports of a component that had been deleted.

@acklavidian
Copy link

Adding this module declaration to a *.d.ts file works like a charm for my purposes:

declare module 'vuetify/lib' {
  import 'vuetify/types/lib'
}

@devpixde
Copy link

devpixde commented Oct 5, 2019

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

remove the /lib from to import Vuetify from 'vuetify';

the error disappears but styles are missing fonts.

declare module 'vuetify/lib' {
import 'vuetify/types/lib'
}

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"
],

@Aurora12
Copy link

Aurora12 commented Oct 5, 2019

@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.

@MajesticPotatoe
Copy link
Member

This is added in the FAQ section of the docs.

@glen-84
Copy link

glen-84 commented Apr 18, 2020

@MajesticPotatoe,

Can this not be fixed properly instead of just documenting a workaround?

@dcb99
Copy link

dcb99 commented May 15, 2020

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.

@ctsstc
Copy link

ctsstc commented May 21, 2020

If you use typeRoot in your tsconfig.json instead of types you will need to instead add:

{
  "compilerOptions": {
    "typeRoots": [
      "./node_modules/vuetify/types"
    ]
  }
}

It seems it would be ideal to have an @types package as well.

@douglasg14b

This comment has been minimized.

@glen-84
Copy link

glen-84 commented Jun 5, 2020

I think this could also be solved with package exports, but this has not yet been implemented in TypeScript.

@vernaschwartz
Copy link

I was having trouble.
Then I used import 'vuetify/dist/vuetify.min.css' in the main.js file and then I deleted the /lib on the vuetify.js file.
And it all worked.

@vuetifyjs vuetifyjs locked as resolved and limited conversation to collaborators Oct 26, 2020
@johnleider
Copy link
Member

@vernaschwartz We kindly ask users to not comment on closed/resolved issues. If you believe that this issue has not been correctly resolved, please create a new issue showing the regression.

If you have any additional questions, please reach out to us in our Discord community.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests