Skip to content

Slot return value should restict type of components  #3552

@tobiasdiez

Description

@tobiasdiez

According to vuejs/core#7982 (comment), the each slot definition can be a function whose return value should restrict what components can be put in that slot. By default, its any or VNode[] which is not restricting anything, but one should be able to specify a certain component.

For example, the restrict slot of a component defined with

defineSlots<{
    default(props: { foo: string; bar: number }): any,
    restict(props: { data: string }): typeof Button[]
  }>()

should only allow Buttons as children.

Playground which also shows that type interference/restriction for children is not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions