docs icon indicating copy to clipboard operation
docs copied to clipboard

Add note about having to call `defineProps` at the top-level

Open darrylnoakes opened this issue 3 years ago • 2 comments

When using defineProps, you have to call it in the form ... = defineProps(). Using it like ... = toRefs(defineProps()) generates a misleading mess of runtime errors, with the only relevant one being that "defineProps is not defined". Currently, the docs for defineProps do not mention this at all. Could a note be added, along with a ESLint rule?

darrylnoakes avatar Oct 04 '22 21:10 darrylnoakes

This does need to be documented better, but I think something should also be added to the SFC compiler to provide a better error message. If it were handled by the compiler then I don't think an ESLint rule would be required.

skirtles-code avatar Oct 14 '22 12:10 skirtles-code

+1 to this being a compiler error instead of just a linting error.

darrylnoakes avatar Oct 14 '22 13:10 darrylnoakes