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

fix(runtime core) : improve slot type definitions #11725

Conversation

Procrustes5
Copy link
Contributor

closes #11671

Description

This PR enhances the Slot type definition to allow for more flexible return types.

Modified Slot type definition

Before: (...args: any[]) => VNode[]
After: (...args: any[]) => VNode[] | VNode | null | undefined

This change allows slot functions to return a single VNode, null, or undefined, better reflecting common patterns in actual Vue components.

Updated the normalizeSlot function to be compatible with the new Slot type.
Added type tests to ensure the new Slot type works as intended.

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 99.1 kB 37.5 kB 33.8 kB
vue.global.prod.js 157 kB 57.3 kB 51 kB

Usages

Name Size Gzip Brotli
createApp 54.5 kB 21.1 kB 19.3 kB
createSSRApp 58.4 kB 22.8 kB 20.8 kB
defineCustomElement 59.1 kB 22.6 kB 20.6 kB
overall 68.1 kB 26.2 kB 23.8 kB

Copy link

pkg-pr-new bot commented Aug 28, 2024

commit: 91ec974

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11725

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11725

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11725

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11725

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11725

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11725

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11725

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11725

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11725

vue

pnpm add https://pkg.pr.new/vue@11725

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11725

Open in Stackblitz

@yyx990803
Copy link
Member

Is this still needed as #11671 is closed?

@Procrustes5
Copy link
Contributor Author

@yyx990803
Oh I've not realized the issue is closed.
Although the issue has been closed, I still think that the slot type can be better when it has a bit looser type. Could you advise me on what to do with this PR?

@Procrustes5 Procrustes5 closed this Oct 6, 2024
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.

Typescript error when trying to expose slot to parents using generic
2 participants