Fix Vue prop defaults for objects/arrays. #12634 #12795
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #12634
What I did
Added a check for whether or not an object/array prop's default value is a factory function, as prescribed by the Vue docs. See #12634 for more details. I also added a story to
vue-kitchen-sink
for testing. I'm not altogether sure how to add a Jest test for theextractArgTypes
function, since I don't feel I fully understand its usage, but am willing to try with some guidance.Also note that I included
'other'
among the types I'm checking against. I tried to restrict this to just'object'
and'array'
, but there is a peculiarity in how docgen works, where if the component's type is specified as[Boolean, Array]
, it gets classified as'other'
. Sorry, that's not a great explanation, but I'm happy to discuss further if it's of concern.How to test
See the new
Varied
story inexamples/vue-kitchen-sink/src/stories/components/button.stories.js
. Previously, this would have produced a warning and broken the component, as described in #12634.Maybe?
One is provided.
No.
If your answer is yes to any of these, please make sure to include it in your PR.