-
Notifications
You must be signed in to change notification settings - Fork 634
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
base: v3
Are you sure you want to change the base?
Conversation
commit: |
Finally managed to fix dynamic typing! Currently everything works for |
This comment was marked as outdated.
This comment was marked as outdated.
Update on the state of this PRDynamic TypingI've standardized as much as possible the type utils that are responsible for dynamically typing const items: NavigationMenuItem[] = [
{
title: 'Home',
to: '/',
test: 1, // non-default type
},
{
title: 'About',
to: '/about',
}
] On this subject I would like to take the opportunity to standardize this one. ATM all the Reka UI components that accept items type with I already drafted and tested locally how to correctly support this with the following structure: interface [COMPONENTNAME]ItemBase<K extends {}> {
title?: string
to?: string
children?: MyItem<K>[]
}
type [COMPONENTNAME]Item<K extends {} = {}> = [COMPONENTNAME]ItemBase<K> & K
// used as follow for the example above
const items: NavigationMenuItem<{
test?: number
}>[] = [
// ...
] But now I would like to list out all those components that we want this to be supported. Some that come on top of my mind are:
SlotsThe current |
π Linked issue
Resolves #2140
Also discussed privately and https://github.com/nuxt/ui-pro/pull/753#issuecomment-2625295701
β Type of 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
Carousel
, because the inferredstring[]
is more than enough.CommandPalette
([CommandPalette] Generics not working well with items inside groupsΒ #2260) will require additional work in separate PRBreadcrumb
have alabelKey?: string
that I was looking for changing with proper inference, 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
*
: means that I might need an additional verification before mergeComponents
Accordion
: docs, generics (ui-pro typecheck error, as expected)Breadcrumb
: docs, genericsButtonGroup
: examplesCalendar
: genericsCarousel
: genericsCommandPalette
: probably will be covered in different PRContextMenu
: docs, generics, dynamicsDropdownMenu
: docs, generics, dynamicsForm
: examplesInputMenu
: examples, generics, dynamicsNavigationMenu
: docs, generics, dynamicsRadioGroup
: docs, generics *Select
: examples, generics, dynamicsSelectMenu
: examples, generics, dynamicsStepper
: docs, genericsTable
: probably will be covered in different PRTabs
: docs, generics