Replies: 1 comment
-
How would the compiler handle cases like dynamic bindings through <Comp
v-bind:[dynamicName]="value"
v-bind="dynamicObject"
/> Or attributes inheritance at the root of a component? <template>
<Comp />
<!-- Required props might be inherited (or not) from unbound attrs on this component -->
</template> One answer might be that the compiler should only complain when it can prove a required property is unassigned (so excluding cases such as those above), which might still be better than nothing. Note that very advanced use-cases might manipulate VDOM before actually rendering it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While the Vue compiler in general is sharp at catching common developer mishaps/typos, missing required component props is one common error I make which slips past the compiler somewhat undetected. While there is a console warning omitted for each of these mishaps, it is not as "in-your-face" as a "regular error", e.g. using a variable which does not exist.
Unless there is some rationale behind this decision that I do not understand, I would like this to be a compiler flag in order for developers to write better apps. It makes no sense (to me) that a required prop being missing is just a warning, as the developer otherwise would have just made it optional if that was their intent.
Beta Was this translation helpful? Give feedback.
All reactions