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

feat(language-core): type support of useSlots and $slots #5055

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

KazariEX
Copy link
Collaborator

No description provided.

Copy link

pkg-pr-new bot commented Dec 16, 2024

Open in Stackblitz

vue-component-meta

npm i https://pkg.pr.new/vuejs/language-tools/vue-component-meta@5055

@vue/language-core

npm i https://pkg.pr.new/vuejs/language-tools/@vue/language-core@5055

vue-component-type-helpers

npm i https://pkg.pr.new/vuejs/language-tools/vue-component-type-helpers@5055

@vue/language-plugin-pug

npm i https://pkg.pr.new/vuejs/language-tools/@vue/language-plugin-pug@5055

@vue/language-server

npm i https://pkg.pr.new/vuejs/language-tools/@vue/language-server@5055

@vue/language-service

npm i https://pkg.pr.new/vuejs/language-tools/@vue/language-service@5055

@vue/typescript-plugin

npm i https://pkg.pr.new/vuejs/language-tools/@vue/typescript-plugin@5055

vue-tsc

npm i https://pkg.pr.new/vuejs/language-tools/vue-tsc@5055

commit: 4554780

@KazariEX KazariEX merged commit 443ddf1 into vuejs:master Dec 16, 2024
5 checks passed
@KazariEX KazariEX deleted the feat/use-slots-type branch December 16, 2024 17:26
@darkbasic
Copy link

image

@KazariEX it used to infer string | number before the 2.2.0 update while now I get this error.

@KazariEX
Copy link
Collaborator Author

KazariEX commented Jan 7, 2025

@darkbasic Now the type of $slots will be inferred from <slot> in the template, you can use a empty defineSlots() to set its type to Record<string, any> explicitly.

@darkbasic
Copy link

@KazariEX thanks, I'll use Record<string, unknown> otherwise I get this error:

image

@FaustineG
Copy link

Thank @KazariEX !

In my case, I didn't need to specify a type, simply defineSlots(); removed the error.

@darkbasic You could probably also use the Slots type from vue, it worked on another typing error for me.
image

@KazariEX
Copy link
Collaborator Author

KazariEX commented Jan 9, 2025

You can also use:

<template v-for="render, name in $slots" :key="name">
  <component :is="render" />
</template>

instead of <slot>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants