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

Feature: Vue 3, defineComponent: Allow to define slots inside defineComponent function #5356

Closed
iliubinskii opened this issue Feb 3, 2022 · 1 comment

Comments

@iliubinskii
Copy link

iliubinskii commented Feb 3, 2022

What problem does this feature solve?

I am trying to create generic component.

I managed to create component with generic props using this tutorial:
https://logaretm.com/blog/generically-typed-vue-components/

However, it does not help to create generic slots because "script" section contains no information about slots.

Adding slots definitions to defineComponent would allow to use technique described here:
https://logaretm.com/blog/generically-typed-vue-components/
to create generic slots.

What does the proposed API look like?

defineComponent({
  slots: {
    slot1: {
      name: "slot-name",
      data: SlotDataType<{ a: string, b: number }>
    }
  }
})

Then tools like Valor could extract slot data types from DefineComponent.

@posva
Copy link
Member

posva commented Feb 3, 2022

Volar already extracts the slot typing. Duplicate of #3102 (Generic components)

@posva posva closed this as completed Feb 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants