vuejs / vetur

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

Undefined variables/properties don't error with Vue Composition API in Vue 2 #1874

Open nsnyder opened 4 years ago

nsnyder commented 4 years ago

Info

Problem

When I'm using the Vue Composition API plugin in Vue 2, Vetur doesn't surface errors for undefined properties. As demonstrated, this is not an issue with the Options Style version.

Browser output:

Screen Shot 2020-04-25 at 7 25 21 PM

VS Code window (split to demonstrate the difference between styles):

Screen Shot 2020-04-25 at 7 26 20 PM

Reproducible Case

https://github.com/nsnyder/typescript-sandbox/tree/demonstrate-vetur-issues Clone and run npm install then checkout the demonstrate-vetur-issues branch.

Please let me know how I can help. Vetur is a great tool to help me write better code! Thanks for everything you put into this!

rfox12 commented 4 years ago

This frustrated me to no end. I've literally spent the last two days working on dev environment setup (but hopefully almost there).

This particular issue is most likely related to this: https://github.com/vuejs/vetur/issues/1509

So the hack-workaround for now: ensure all your Composition API setup functions have props. Once you add a props object then you'll notice Vetur's nice problem detection kicks in again.

nsnyder commented 4 years ago

@rfox12 Thank you! A workaround, to be sure, but one that'll give me a little extra peace-of-mind as I do my day-to-day coding until it's fixed.

myknbani commented 3 years ago

I can confirm that adding an empty props would bring back the red squigglies.