Skip to content

Export ExtractPropTypes for shared props #628

@kiroushi

Description

@kiroushi

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" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions