Document PropType usage with the Composition API #2157
Merged
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.
Closes #1621.
Add documentation about working with complex types for props in the Composition API.
Specifically,
PropType
isn't currently mentioned on the page about using TypeScript with the Composition API. It only features on the page about the Options API.The original suggestion, on #1621, was to document this near the top of the page, before we start discussing type-based prop declaration. That was my original plan, but I felt there were a few problems with that approach:
props
option, which also usesPropType
for complex types.PropType
.I also didn't want to repeat everything that's on the Options API page.
With those considerations in mind, I've added a separate section to the end of the section about props. It documents using complex types with the three different approaches. The examples are based on those in the Options API TS docs, but I haven't gone into the same level of detail as those examples. I've included a link to the Options API TS docs for anyone who wants more examples, but I don't think there's any essential information missing.