Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
victorgarciaesgi opened this issue Feb 2, 2021 · 9 comments
Open
4 tasks done

Comments

@victorgarciaesgi
Copy link

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: macOs
  • Vetur version: 0.32.0
  • VS Code version: 1.52.1

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
Copy link
Member

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

@victorgarciaesgi
Copy link
Author

@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
Copy link
Member

@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 #2343 and #2344

@duola8789
Copy link

So, no solution?

@earslap
Copy link

earslap commented Sep 14, 2021

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: #2857 (comment)

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
Copy link

Same problem here

@calebwaldner
Copy link

calebwaldner commented Sep 30, 2021

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.

@yoyo930021 yoyo930021 added this to the v0.36.0 milestone Oct 5, 2021
@GoodiesHQ
Copy link

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

@lgarczyn
Copy link

lgarczyn commented Jan 22, 2022

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'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants