Skip to content

Document PropType usage with the Composition API #2157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

skirtles-code
Copy link
Contributor

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:

  • The page also mentions the props option, which also uses PropType for complex types.
  • That earlier section seems to be trying to encourage the use of type-based declaration. Runtime declaration is glossed over very quickly. Adding a more detailed explanation would delay mentioning the 'recommended' approach.
  • The docs don't currently show how to use complex types with type-based declaration. It may be 'obvious', but without mentioning it explicitly I think someone could get confused and think they need to do something with 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.

@netlify
Copy link

netlify bot commented Jan 8, 2023

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 389d20b
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/63ba5e5d9bf8d000096d02e5
😎 Deploy Preview https://deploy-preview-2157--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@NataliaTepluhina NataliaTepluhina merged commit a679e81 into vuejs:main Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript with Composition API: Document use of PropType
2 participants