Skip to content
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

Export ExtractPropTypes for shared props #628

Closed
kiroushi opened this issue Jan 13, 2021 · 3 comments
Closed

Export ExtractPropTypes for shared props #628

kiroushi opened this issue Jan 13, 2021 · 3 comments

Comments

@kiroushi
Copy link
Contributor

kiroushi commented Jan 13, 2021

It would be good that this type was exported so it could help with props that are shared with other components (formerly mixins).

Example use case:

export const sharedProps = {
  disabled: Boolean,
}

export function getSharedPropBindings (props: ExtractPropTypes<typeof sharedProps>) {
  return computed(() => ({
    disabled: props.disabled,
  }))
}

Later in component:

Script

import { sharedProps, getSharedPropBindings } from './sharedProps'

// setup block
const sharedPropBindings = getSharedPropBindings(props)

Template

<component v-bind="sharedPropBindings" />
@antfu
Copy link
Member

antfu commented Jan 13, 2021

vue-next exports it as well. I don't see any reason why we shouldn't. Would you like to draft a PR for it? Thanks.

@antfu
Copy link
Member

antfu commented Jan 14, 2021

Heading for a release, I will fix it for now. Thanks!

@antfu antfu closed this as completed in 903a0aa Jan 14, 2021
@kiroushi
Copy link
Contributor Author

Apologies @antfu, was pretty busy and I couldn’t find a spot to get with it. Thanks for taking care of it 💪

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 a pull request may close this issue.

2 participants