WebStorm Nuxt 3 TypeScript not working in template

Hi,

I created new project to try out Prisma. I created server routes with Nuxt 3. I'm using useFetch, which returns type generated from Prisma. I can see that in script tag, but this doesn't work in template tag. I didn't do anything else then npx nuxi init <project-name>.

Do you have any idea why is this happening? (Also there is .js file icon showing, which I find weird, since I'm using ts).


0
10 comments

Could you share a sample project the issue can be reproduced with?

0

I have similar issues with Vue x Nuxt3 refs in template.

It seems to especially be problematic if imports of ref/Ref are not done explicitly in the vue component.

Among many other things, ref (function) and Ref (type) are auto-imported by Nuxt, so explicitly importing them is 100% redundant as the code will function the same regardless if you import them, except WebStorm often has trouble understanding what's going on if the imports statements are omitted.

Another auto-imported function that often break WebStorm's typing system: computed

Compare these cases:

Before import:

in script:

in template:

You can see type information is completely broken / missing / borked.

After adding 

import { computed } from 'vue';

this becomes:

This fixes the typing information at the cost of adding needless import statements. I say needless because the code doesn't need them, but WebStorm sadly does need them until it is fixed. But not all cases can be solved by an import because often the return types of functions in the setup script are using auto-imported types without explicitly stating/naming these types, so importing them doesn't do anything and the typing remains broken, sadly. The prisma related issues likely face the same issues as mentioned here

0

Elena Pogorelova In the thread you mention a comment says that the thread is NOT about Nuxt3 but instead about pure Vue + plugins. Which is kind of weird because the issue there is due to Nuxt auto-imports which are a core feature of Nuxt (not some plugin)

Another comment says the this problem for Nuxt3 will be fixed in full release of v2023.1.1, I hope that is true because in the 2023.1.1 Beta version it is still not fixed

0

2023.1.1 Beta is not yet available, what you are using is 2023.1 Beta; 2023.1.1 is a minor update of 2023.1 (that is not yet released). Once it's released, we'll start the EAP process for 2023.1.1

1

Blessed, looking forward to the 1.1 update!

0

Hi guys,

I use the 2023.1.3 version, which still struggles with Nuxt 3 and typescript.

Is there something I can do right now to solve the issue?

Best regards,
Luis.

2

What problems using  Nuxt 3 and typescript you have faced? Please file tickets to youtrack, https://youtrack.jetbrains.com/issues/WEB, providing the detailed issue description

0

Please sign in to leave a comment.