vuetify: [Bug Report] No typings for importing "A La Carte" components

Versions and Environment

Vuetify: 1.0.17 Vue: 2.5.16 Browsers: Chrome 66.0.3359.117 OS: Windows 10

Steps to reproduce

Run

$ npm install -g vue-cli
$ vue init vuetifyjs/a-la-carte my-project
$ cd my-project
$ npm install
$ npm run dev

Then you add typescript support to my-project (change main.js to main.ts etc…) by following the official vue page on typescript or something like https://github.com/Microsoft/TypeScript-Vue-Starter

Attempting to run this (i.e. npm run dev) will result in errors such as:

      TS2305: Module '"...../node_modules/vuetify/index"' has no exported member 'VBtn'.

which pertaining to the following import lines in main.ts

import {
  Vuetify,
  VApp,
  VNavigationDrawer,
  VFooter,
  VList,
  VBtn,
  VIcon,
  VGrid,
  VToolbar,
  transitions
} from 'vuetify'

Expected Behavior

no errors. should build and run fine.

Actual Behavior

has errors doesn’t build or run

Reproduction Link

https://github.com/vuetifyjs/vuetify/blob/dev/index.d.ts

Other comments

Please update https://github.com/vuetifyjs/vuetify/blob/dev/index.d.ts You will see over there, that there are actually no references to exported A La Carte components etc…

Note that Even though this pertains to A La Carte, it must actually be fixed in the main vuetify repo is why this issue has been opened here.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 39 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Solved the issue by adding vuetify to tsconfig compiler types

{
	"compilerOptions": {
                ...
		"types": ["node", "jest", "vuetify"],
                ...
}

I added vuetify with the CLI and got the typescript error. This solution worked for me: https://github.com/vuetifyjs/vuetify/issues/3943#issuecomment-414551981

TLDR: In tsconfig.json add vuetify to the list of types

this problem still exists in Vuetify 2, even after adding “vuetify” to types (in tsconfig.json)

 "include": [
        ..., // let the default includes
        "node_modules/vuetify/types", // add this one
    ]
  "exclude": [
    "node_modules/^(?!vuetify/types).*$" // change the default exclude rule to this
  ],

Just that and it’s ok.

I added vuetify with the CLI and got the typescript error. This solution worked for me: #3943 (comment)

TLDR: In tsconfig.json add vuetify to the list of types

I think this should be added into the document of https://vuetifyjs.com/en/framework/a-la-carte

You need "types": ["vuetify"] in tsconfig, I haven’t got around to fixing it in the cli plugin yet.

Is this supposed to be fixed? Just created test project with vue-cli 3 with typescript and still got this problem. All a la carte imports apart first one - vuetify - are erroneous.

Unfortunately, this is still an issue, and quite annoying for newcomers to Vue/Vuetify/TypeScript: "ERROR in C:/Users/nemet/tiva11/tiva11forvue/src/plugins/vuetify.ts 2:21 Could not find a declaration file for module ‘vuetify/lib’. …/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';

Fortunately, @pascoual solution worked to me, either.

same here: Could not find a declaration file for module 'vuetify/lib

@KaelWD adding “types”: [“vuetify”] in tsconfig doesn’t solve the problem unfortunately. I am getting similar error. [ts] ‘Vuetify’ only refers to a type, but is being used as a value here.

Why do we need typings when the source is already typescript?

Hey,

I tried the above steps and am getting the following:

[ts] Could not find a declaration file for module 'vuetify/es5/components/transitions'. '.../node_modules/vuetify/es5/components/transitions/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';`

“dependencies”: { “@types/nprogress”: “0.0.29”, “firebase”: “^5.3.0”, “nprogress”: “^0.2.0”, “register-service-worker”: “^1.0.0”, “spinkit”: “^1.2.5”, “vee-validate”: “^2.1.0-beta.7”, “vue”: “^2.5.16”, “vue-class-component”: “^6.0.0”, “vue-property-decorator”: “^7.0.0”, “vue-router”: “^3.0.1”, “vuetify”: “^1.2.0-beta.0”, “vuex”: “^3.0.1”, “vuex-class”: “^0.3.1” }, “devDependencies”: { “@babel/polyfill”: “^7.0.0-beta.55”, “@types/jest”: “^23.3.1”, “@vue/cli-plugin-babel”: “^3.0.0-rc.10”, “@vue/cli-plugin-e2e-cypress”: “^3.0.0-rc.10”, “@vue/cli-plugin-eslint”: “^3.0.0-rc.10”, “@vue/cli-plugin-pwa”: “^3.0.0-rc.10”, “@vue/cli-plugin-typescript”: “^3.0.0-rc.10”, “@vue/cli-plugin-unit-jest”: “^3.0.0-rc.10”, “@vue/cli-service”: “^3.0.0-rc.10”, “@vue/eslint-config-standard”: “^3.0.0-rc.10”, “@vue/eslint-config-typescript”: “^3.0.0-rc.10”, “@vue/test-utils”: “^1.0.0-beta.23”, “babel-core”: “7.0.0-bridge.0”, “babel-plugin-transform-imports”: “^1.4.1”, “node-sass”: “^4.9.0”, “sass-loader”: “^7.0.1”, “stylus”: “^0.54.5”, “stylus-loader”: “^3.0.1”, “ts-jest”: “^23.0.0”, “typescript”: “^3.0.0”, “vue-cli-plugin-vuetify”: “^0.1.6”, “vue-template-compiler”: “^2.5.16” }

will you consider creating a new issue to for the transform-imports / ts-import-plugin aspect. we want to be able to use this with typescript as closely as one would use it with regular js… there should be no disadvantages to using this lib with ts… only advantages 😃