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

defineSlots<SlotInterface>() missing slotNames #10425

Open
el-j opened this issue Feb 28, 2024 · 3 comments
Open

defineSlots<SlotInterface>() missing slotNames #10425

el-j opened this issue Feb 28, 2024 · 3 comments
Labels
need more info Further information is requested

Comments

@el-j
Copy link

el-j commented Feb 28, 2024

Vue version

latest

Link to minimal reproduction

no link provided, same in every vue component.

Steps to reproduce

Try to get the name(s) of the (named) slots that are useable with an imported component.

there is no way in knowing the names of the slots that can be used. even if there is a slot-interface, the names of the slots are unknown, and so not really use full.

there must be a way to get the slotNames of the typed defineSlots().

What is expected?

const slots = defineSlots()

slots should at least have the names of the slots from the definedSlots SlotInterface.

What is actually happening?

slots are not known, slots are not accessible, defined slots from components are not useable as the names are not known to the user.

System Info

mac m3
vs code 
vue latest

Any additional comments?

assign the slotsNames to props or something like that.

@pikax
Copy link
Member

pikax commented Feb 29, 2024

@el-j can you provide more information

Seems to be working to me playground

import { defineSlots } from 'vue'

const slots = defineSlots<{ a: () => any }>()

slots.a()
//@ts-expect-error  
slots.aaa()

image

@pikax pikax added the need more info Further information is requested label Feb 29, 2024
@LinusBorg
Copy link
Member

If I had to guess, OP wants a way to read the available slot names from a component definition at runtime or something like that?

Not sure though ...

@el-j
Copy link
Author

el-j commented Mar 1, 2024

Hi, yes so indeed it's not about define slots and use them in the component. Its about useing the component and know the possible slot names or generically put in/fill all possible slots.
Sorry if i was not clear on that.

If i import a component i can get slmething like
component.props but cannot get component.slots (or emits...(but that might be another issue)

I would love to import a component and consider the slots and their content from within the script section. I am writting in typescript sfc style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants