Skip to content

docs: add Typing Component Slots section to TypeScript guide - #3479

Merged
bencodezen merged 3 commits into
vuejs:mainfrom
dilipsaroj:docs/typing-component-slots
Nov 16, 2026
Merged

bencodezen merged 3 commits into
vuejs:mainfrom
dilipsaroj:docs/typing-component-slots

Conversation

@dilipsaroj

@dilipsaroj dilipsaroj commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description of Problem

The TypeScript with Composition API guide documents typing props and emits, but not slots. defineSlots() is only covered in the API reference.

Forwarding slot props in a recursive component (<slot v-bind="slotProps" />) also gives TS7022 ('slotProps' implicitly has type 'any'), and the docs don't explain how to fix it.

Proposed Solution

Add a "Typing Component Slots" section to guide/typescript/composition-api.md:

  • basic defineSlots() usage, linking to the API reference
  • a "Forwarding Slots in Recursive Components" subsection showing that declaring the slot type with defineSlots() fixes the TS7022 error

Additional Information

I checked both examples with vue-tsc (Vue 3.5, TypeScript 5.9). Without defineSlots() the recursive example reports TS7022; with it, it type-checks.

Closes #3475
Part of #2371

@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 6668482
🔍 Latest deploy log https://app.netlify.com/projects/vuejs/deploys/6afb28f76d253864a3698713
😎 Deploy Preview https://deploy-preview-3479--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/guide/typescript/composition-api.md Resolved
Comment thread src/guide/typescript/composition-api.md Resolved
Comment thread src/guide/typescript/composition-api.md Resolved
Comment thread src/guide/typescript/composition-api.md Resolved

@bencodezen bencodezen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I made some tweaks to improve the clarity of the message, but really apprecaite it @dilipsaroj!

@bencodezen
bencodezen merged commit f66b582 into vuejs:main Nov 16, 2026
3 of 4 checks passed
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.

Slots in recursive components

2 participants