import { RoutesAPI } from '.././RoutesAPI'; import { RouteParams, QueryParams } from '.././GetParams'; import { RouteConfig } from '.././RouteConfig'; import { RequiredKeys, OptionalKeys, CleanIntellisense } from '.././typescript'; import { UseQueryParams } from './makeUseQueryParams'; import { PreserveBothParams, PreserveParamsOnly, PreserveQueryParamsOnly, PreserveNeitherParams } from '.././SmartParamConfig'; type KeysThatCanBeOptional = Extract | RequiredKeys>; type _PartialOfParamsWeAlreadyHave = CleanIntellisense<{ [K in KeysThatCanBeOptional]?: TNextParams[K]; } & { [K in Exclude>]: TNextParams[K]; }>; type PartialOfParamsWeAlreadyHave = _PartialOfParamsWeAlreadyHave, // these are the params we already have (from current route context) RouteParams>; type KeysOfFullyOptional = { [N in keyof R]: {} extends PartialOfParamsWeAlreadyHave ? N : never; }[keyof R]; type SmartRoute = { (routeName: N, givenParams: PartialOfParamsWeAlreadyHave, givenQueryParams?: QueryParams): string; >(routeName: N): string; }; export type LenientSmartRoute = (routeName: N, givenParams?: Partial>, givenQueryParams?: QueryParams) => string; type StrictSmartRoute = (routeName: N, givenParams: RouteParams, givenQueryParams?: QueryParams) => string; export type UseSmartRoute = { (currentRouteName: TCurrentRouteName): SmartRoute; (currentRouteName: TCurrentRouteName, smartParamConfig: PreserveBothParams | PreserveParamsOnly): SmartRoute; (currentRouteName: TCurrentRouteName, smartParamConfig: PreserveQueryParamsOnly): StrictSmartRoute; (): LenientSmartRoute; (smartParamConfig: PreserveBothParams | PreserveParamsOnly): LenientSmartRoute; (smartParamConfig: PreserveQueryParamsOnly): StrictSmartRoute; (smartParamConfig: PreserveNeitherParams): unknown; (currentRouteName: TCurrentRouteName, smartParamConfig: PreserveNeitherParams): unknown; }; export declare function makeUseSmartRoute(route: RoutesAPI['route'], path: RoutesAPI['path'], paramNames: RoutesAPI['paramNames'], useQueryParams: UseQueryParams): UseSmartRoute; export {};