Skip to content

Typescript Slot-Typings for HyperScript Components #8096

Closed
@tada5hi

Description

@tada5hi

What problem does this feature solve?

At the moment slot typings are only available for components that are written in vanilla vue. Components that are written in HyperScript and therefore do not have a template block cannot currently provide typings. Therefore it would be useful to be able to define which (named) slots the component provides, similar to props.

What does the proposed API look like?

The idea here would be that if a type is specified, than it describes the type of the slot property. If no type is specified, it is a slot without slot properties.

import type { PropType } from 'vue';
import { defineComponent } from 'vue';

type SlotType = PropType;
type MyType = {
    attr: string
}

export default defineComponent({
     slots: {
          default: {
                type: Object as SlotType<MyType>,
          },
          named: {
          
          }
     } 
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions