Closed nagylzs closed 3 weeks ago
Note: when I insert a CamelCase tag into the template, its import statement is added to the setup automatically, e.g.
<script setup lang="ts">
import { VImg } from 'vuetify/components/VImg';
import { VCard, VCol, VOverlay, VRow } from 'vuetify/lib/components/index.mjs';
//
</script>
and only the <v- tags for these imported classes can be autocompleted.
vuetify template does not include the type file in tsconfig ( or anywhere in the code). So typescript server does not know.
see node_modules/vuetify/dist/vuetify.d.ts
a related issue in vuetify repo : https://github.com/vuetifyjs/vuetify/issues/17269
I'm trying to switch from React to Vue, and the missing type declarations make the transition quite difficult. I don't "remember" the property/slot names, because I have zero experience with Vue and Vuetify.
Haven't using vuetify for ages but had a try. You can add vuetify
to types
array in tsconfig
. ( as it declared in vuetify package.json )
e.g.
"types": [ "vuetify" ],
but because i am using pnpm so i have to change @vue/runtime-core
to vue
in node_modules/vuetify/lib/index.d.mts
I guess if you use yarn that should be fine.
PS: this issue isn't about vue or react, it's a typescript thing.
yarn create vuetify
generated this in tsconfig.json
"types": [
"vite/client",
"vite-plugin-vue-layouts/client",
"unplugin-vue-router/client"
],
Changed to:
"types": [
"vite/client",
"vite-plugin-vue-layouts/client",
"unplugin-vue-router/client",
"vuetify"
],
and restarted vs code, but it did not help. Then I canged node_modules/vuetify/lib/index.d.mts
from this:
declare module '@vue/runtime-core' {
to this:
declare module 'vue' {
and restarted vs code again, but it did not help. Actually it made things worse, because now not even (property) VRow : any
shows up when I hover the pointer over a <v- element.
PS: this issue isn't about vue or react, it's a typescript thing.
If it is possible to set this up correctly, then shouldn't yarn create vuetify
do it?
I double checked vuetify's tsconfig file, I think something's missing e.g. it does not include files under src. Maybe worth to open an issue for that.
Try to change this to your includes, I copied from my another vue project
"include": [
"**/*.ts",
"**/*.js",
"**/*.d.ts",
"**/*.tsx",
"**/*.vue",
"tests/setup.ts"
],
Try to change this to your includes, I copied from my another vue project
"include": [ "**/*.ts", "**/*.js", "**/*.d.ts", "**/*.tsx", "**/*.vue", "tests/setup.ts" ],
After adding that, I can autocomplete <v- tags and I can see their types. Color is changed to green
I'm submitting a bug report to vuetify.
Thank you for your help!
This is ridiculous. It is not possible to create this issue, because they only allow to create issues with the issue creator, and that is a form that requires me to add a "reproduction link" on play.vuetifyjs.com
But obviously, this error with tsconfig and intellisense/autocomplete is not something that can be demonstrated on the playground site.
And then, "Issues must be created with this form or they will be closed immediately."
I'm not sure how to submit this bug. :-(
I think this is the right repo
Please see the video below. <v- tags are no recognized, autocompletete does not work by default. However, if I use the full class name then autocomplete works for any component, and after that it also works for <v- tags.
It is very easy to reproduce, just create a new vuetify typescript project
yarn create vuetify
then open it in vscode (with vue official plugin installed).Version: 1.90.0 Commit: 6319a0b6210a13408ab1ef44be93444143942ea8 Date: 2024-05-03T07:47:29.201Z Electron: 28.3.1 ElectronBuildId: undefined Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.6.30-2-MANJARO Vue plugin version 2.0.17
https://github.com/vuejs/language-tools/assets/15814836/013bc1c9-4580-4847-a595-de001f804082