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(components): improve generic types #3331

Merged
merged 114 commits into from
Mar 24, 2025
Merged

fix(components): improve generic types #3331

merged 114 commits into from
Mar 24, 2025

Conversation

sandros94
Copy link
Member

@sandros94 sandros94 commented Feb 16, 2025

πŸ”— Linked issue

Resolves #2140
Resolves #3670
Resolves #3606

Also discussed privately and https://github.com/nuxt/ui-pro/pull/753#issuecomment-2625295701

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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

The main goal for this PR is to both simplify the use of types as well as properly document them for each component that might use them.

Notes

  • I'm not adding type examples for some components, like Carousel, because the inferred string[] is more than enough.
  • Commit 5203359 might seem a breaking change (order of type generics), but it is how it should actually work (it also standardize between components).
  • CommandPalette ([CommandPalette] Generics not working well with items inside groupsΒ #2260) will require additional work in separate PR. Similarly for named slots within children (for those components that do support it), as they might require a similar approach.
  • Some components, like Breadcrumb have a labelKey?: string that I was looking for changing with proper typing, but for some reason they all break the forwarding of props

πŸ“ Components Checklist

As this PR touches basically almost all components here is a brief description on what changed for what component.

Legend

  • docs: means types have been added to doc (both markdown as well as vue component examples)
  • examples: means that types have been added only to related component example in docs
  • generics: means that I both added default types to generics as well as I might have reordered them (I don't consider this change a breaking change because it favors proper behavior)
  • dynamics: means that the component has been fully worked on and support proper dynamic typing based on input props (both arrays, nested ones, filters, modelValues, label/value keys)
  • *: means that I might need an additional verification before merge

Components

  • Accordion: docs, generics (ui-pro typecheck error, as expected)
  • Breadcrumb: docs, generics
  • ButtonGroup: examples
  • Calendar: generics
  • Carousel: generics
  • CommandPalette: probably will be covered in different PR
  • ContextMenu: docs, generics, dynamics
  • DropdownMenu: docs, generics, dynamics
  • Form: examples
  • InputMenu: examples, generics, dynamics
  • NavigationMenu: docs, generics, dynamics
  • RadioGroup: docs, generics *
  • Select: examples, generics, dynamics
  • SelectMenu: examples, generics, dynamics
  • Stepper: docs, generics
  • Table: probably will be covered in different PR
  • Tabs: docs, generics

Copy link

pkg-pr-new bot commented Feb 16, 2025

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

commit: 445c7cb

@benjamincanac benjamincanac merged commit b998354 into v3 Mar 24, 2025
10 of 11 checks passed
@benjamincanac benjamincanac deleted the refactor-types branch March 24, 2025 20:38
@Gobler
Copy link
Contributor

Gobler commented Apr 1, 2025

I updated the version today - in theory looking at the changelog it should fix the problems but unfortunately I'm still getting a lot of TS error messages on files/components I'm not using within my project... I've already tried clearing the cache, deleted all dependency files and builds etc unfortunately the problem is still there.... any hints as to what is wrong or what I can check/fix?
Zrzut ekranu 2025-04-1 o 07 14 28

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