ui icon indicating copy to clipboard operation
ui copied to clipboard

fix(components): improve slots return types

Open sandros94 opened this issue 4 months ago โ€ข 7 comments

๐Ÿ”— Linked issue

Resolves #5232

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [x] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Until the last update for the builder we weren't able to properly and strongly type various aspects about props, slots and emits. Now the issue has been fixed by slots were left unchanged (all being required and return was any). With this change normal use in the template won't change, but does greatly increase the typing experience when using render functions (required for the current UTable implementation).

๐Ÿ“ Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

sandros94 avatar Oct 15 '25 14:10 sandros94

@benjamincanac could I ask you to double check the various default slots and which could be optional and which must be required? For example most of Prose* components would require the default slot, as well the Form* components.

sandros94 avatar Oct 15 '25 14:10 sandros94

npm i https://pkg.pr.new/@nuxt/ui@5237

commit: b9369eb

pkg-pr-new[bot] avatar Oct 16 '25 17:10 pkg-pr-new[bot]

@sandros94 Should we also update all resolveComponent instances with #components import?

benjamincanac avatar Oct 17 '25 08:10 benjamincanac

@sandros94 Should we also update all resolveComponent instances with #components import?

To provide typing? Shouldn't resolveComponent also resolve them?

sandros94 avatar Oct 17 '25 09:10 sandros94

It doesn't work on my end, but if you say resolveComponent works why bother rewriting all slots? ๐Ÿค”

benjamincanac avatar Oct 17 '25 09:10 benjamincanac

When writing in tsx with h it provides type error when passing invalid objects and classes as return, as they need proper destructuring/stringification (something we are used with via {{ ... }} in the template)

sandros94 avatar Oct 17 '25 09:10 sandros94

Yes but only when importing from #components not when using resolveComponent right?

benjamincanac avatar Oct 17 '25 09:10 benjamincanac