N
Nuxt9mo ago
nico

Resolving TS2307 Error for Dynamic Component Imports in Nuxt 3

Any idea how I could potentially fix my TS2307: Cannot find module without using a ts-ignore? 😅 The components are not used normally and I get that they are throwing this error because I am not using them this way but in this dynamic way but there has to be a way to fix those without using a ts-ignore?
No description
12 Replies
Gosu
Gosu9mo ago
Could you solve it? I have a similar problem but only in stories and tests in version 3.11.0
nico
nicoOP9mo ago
nope, just added ts-ignores for now but I don’t know how to fix that
pyplacca
pyplacca9mo ago
Depending on how and where you created the component files, you might’ve to restart the server to help vscode find them
nico
nicoOP9mo ago
its webstorm and this error is there for like 2 months now (readded node modules and .nuxt like 100 times since), thats not the problem.
pyplacca
pyplacca9mo ago
Oh okay
nico
nicoOP9mo ago
“Any idea how I could potentially fix my TS2307: Cannot find module […]” but thanks for trying to help anyway
nico
nicoOP9mo ago
Pretty sure that it is because of my usage of dynamic components ->
<component :is="currentStep" @next="nextStep" @prev="prevStep" class="bg-neutral-900" />
<component :is="currentStep" @next="nextStep" @prev="prevStep" class="bg-neutral-900" />
No description
pyplacca
pyplacca9mo ago
So have u resolved it?
nico
nicoOP9mo ago
Nope still having trouble with this
nico
nicoOP9mo ago
This right here would be a workaround but its not that smooth and doesnt fit for other areas with a lot more components :/
No description
Enzo F.
Enzo F.9mo ago
Hi, I am not sure if this would work for you, but in my case I had to do this
const tenantForm = defineAsyncComponent(() => import('~/components/dialog/Tenant.vue'))
const tenantForm = defineAsyncComponent(() => import('~/components/dialog/Tenant.vue'))
and when I had to use my component as a prop I used it with: markRaw(tenantForm)
nico
nicoOP9mo ago
JetBrains just released WebStorm v2024.1, they have done some things with the Vue language server and somehow after updating it worked 😅 I knew that it was because of my editor but I thought I could somehow declare it as right and defineAsyncComponent may work too but the update seems to have fixed it for now. Still thanks for your suggestion. 🙂
No description
Want results from more Discord servers?
Add your server