Auto-import of /utils not working in VS-Code in template block
Even though my application builds and works fine, the auto-import of my function
t()
doesn't get recognized inside the <template>
.
The function is defined like this:
Inside the <script setup lang="ts">
block the auto-import works,
but in the <template>
block it doesn't.
If I add import { t } from '~/utils/translate.ts'
to the script it starts working in the template, but that would
defy the usefullness of auto-imports.
Gives me the error:
Does anyone know how to get this working?12 Replies
1. check
<rootDir>/.nuxt/imports.d.ts
for export { t } from '../utils/translate';
or similar.
2. if the above exists, restart vscode?
3. if the above does not exist, run nuxt prepare
and repeat first two steps.Hey, thanks for the help.
Unfortunately none of the suggestions work π’
export { t } from '../utils/translate
is there in imports.d.ts
, but restarting VS-Code didn't fix.
Within <script>
block no error, but within <template>
this problem is still not fixed.
I also tried another editor (Zed) --> same problem.Are you using vuetify?
Hey there, i have the same problem, my utils files arent getting recognized by typescript.
Im using Vuetify
i got the same problem - others have aswell https://discord.com/channels/473401852243869706/1270328509784522753
Yes, using Vuetify indeed.
Yea likely an augmenting issue. Have seen this with a lot of libs. Even using nuxt-nightly, which claims to resolve this, still seeing this issue. Worth tracking on gh for now.
Seems like a solution PR is in the making for the next 3.x version: https://discord.com/channels/473401852243869706/1270328509784522753
Thanks π. Useful link!
Ppl still have this problem right? (Cause I do)
add this to
declarations.d.ts
in your project root
Thanks so much for this workaround!
Thanks indeed!