nuxt / nuxt/module-builder

Nuxt 4 module author: Component slot prop types missing.

Open
#701 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
275
Forks
35
Avg merge
4h 42m
Merged PRs (30d)
6

Description

Environment
  • Operating System: Darwin
  • Node Version: v22.14.0
  • Nuxt Version: 4.2.1
  • CLI Version: 3.30.0
  • Nitro Version: 2.12.9
  • Package Manager: npm@10.9.2
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -
Reproduction

Public github repo:

https://github.com/juanpscotto/nuxt-4-module-starter-types-issue

Stackblitz:

https://stackblitz.com/github/juanpscotto/nuxt-4-module-starter-types-issue?file=src%2Fruntime%2Fcomponents%2FNavigationComponent.vue%3AL29

In stackblitz wait until the project is setup. Or run this command npm run dev:prepare && npm run prepack if running locally.

Once it has finished check the dist/runtime/components/NavigationComponent.d.vue.ts file, the slot type is missing.

Additional context

There is one component NavigationComponent that has a named slot content with a data prop array of type NavigationItem[]. That type is carried over as any in both NavigationComponent.d.vue.ts and NavigationComponent.vue.d.ts files

NavigationComponent.vue:

Image

NavigationComponent.d.vue.ts

Image
Describe the bug

The slot props types are not being carried over to the generated .ts files of the .vue components. I expect the type of the data props to be recognized.

Image
Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction and run npm run dev:prepare && npm run prepack. Inspect the generated dist/runtime/components/NavigationComponent.d.vue.ts and NavigationComponent.vue.d.ts, comparing the content slot's data prop with NavigationItem[] from NavigationComponent.vue. Done means the generated declarations preserve the slot prop type instead of emitting any.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.