vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 594 forks source link

False-positive error showing when importing a Typescript interface #2668

Open victorgarciaesgi opened 3 years ago

victorgarciaesgi commented 3 years ago

Info

Problem

In a lot of files I have this error showing when using Typescript interfaces.

I think it's coming from templateProps and infered emit events because generaly the type concerned is used in components props or in the typed emit event using vue-property-decorator:

@Emit('update') updateUser(user:User) {}

image

yoyo930021 commented 3 years ago

If you can provide a repro project, we can study it quickly.

victorgarciaesgi commented 3 years ago

@yoyo930021 Will do, definetly think it comes from $emit events inference from child components after testing some behaviours.

In this file I have this component:

image

The event in question in SelectContributorItem:

image

yoyo930021 commented 3 years ago

@yoyo930021 Will do, definetly think it comes from $emit events inference from child components after testing some behaviours.

In this file I have this component:

image

The event in question in SelectContributorItem:

image

Follow https://github.com/vuejs/vetur/issues/2343 and https://github.com/vuejs/vetur/issues/2344

duola8789 commented 3 years ago

So, no solution?

earslap commented 3 years ago

Any workarounds for this issue? It's not just a false-positive error, since the template checker can't find / import the type, in the template the prop shows up as "any" so type checking for that subcomponent is bypassed as well.

A good and simple repro is here: https://github.com/vuejs/vetur/issues/2857#issue-854937961

Edit: FWIW switching to Volar solved this and many other issues for me. Absolutely not a dig for Vetur contributors here, just that Volar saved the day for me!

calebwaldner commented 3 years ago

Same problem here

calebwaldner commented 3 years ago

Wow, Volar did the trick for me too. I tried what @earslap suggested using Volar and it seems to work. I had to disable Vetur>Validation Interpolation as well, but Volar seems to be fulfilling the gap for the time being. I've love to use Vetur Validation Interpolation when this gets resolved.

GoodiesHQ commented 3 years ago

Still experiencing this issue, though switching to Volar for the time being does seem to solve it.

lgarczyn commented 2 years ago

This happened to me because @Props and @Emit from vue-property-decorator were using typescript types as Objects.

I couldn't fix it for emits, but for props you need to use "import type" instead of "import" on interfaces

It is possible to ask eslint to fix this, using @typescript-eslint/consistent-type-import with { prefer: 'import-types'}