T
TanStack2y ago
extended-salmon

Extending PathParamOptions and similar

What's the proper way to extend PathParamOptions? At the moment I'm doing the following:
export type TabItemInner<
TRouteTree extends AnyRoute = RegisteredRouter["routeTree"],
TFrom extends RoutePaths<TRouteTree> | string = string,
TTo extends string = "",
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
> = {
label: string;
icon?: React.ReactElement | string;
to: ToPathOption<TRouteTree, TFrom, TTo>;
disabled?: boolean;
} & PathParamOptions<TRouteTree, TFrom, TTo, TResolved>;

export type TabItem<
TRouteTree extends AnyRoute = RegisteredRouter["routeTree"],
TFrom extends RoutePaths<TRouteTree> | string = string,
TTo extends string = "",
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
> = TabItemInner<TRouteTree, TFrom, TTo, TResolved>;
export type TabItemInner<
TRouteTree extends AnyRoute = RegisteredRouter["routeTree"],
TFrom extends RoutePaths<TRouteTree> | string = string,
TTo extends string = "",
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
> = {
label: string;
icon?: React.ReactElement | string;
to: ToPathOption<TRouteTree, TFrom, TTo>;
disabled?: boolean;
} & PathParamOptions<TRouteTree, TFrom, TTo, TResolved>;

export type TabItem<
TRouteTree extends AnyRoute = RegisteredRouter["routeTree"],
TFrom extends RoutePaths<TRouteTree> | string = string,
TTo extends string = "",
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
> = TabItemInner<TRouteTree, TFrom, TTo, TResolved>;
This returns a union of the parameters when I try and use it.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?