85 lines
1.8 KiB
Plaintext
85 lines
1.8 KiB
Plaintext
import type {
|
|
AnyRouter,
|
|
Constrain,
|
|
InferFrom,
|
|
InferMaskFrom,
|
|
InferMaskTo,
|
|
InferSelected,
|
|
InferShouldThrow,
|
|
InferStrict,
|
|
InferTo,
|
|
RegisteredRouter,
|
|
} from '@tanstack/router-core'
|
|
import type { LinkComponentProps } from './link'
|
|
import type { UseParamsOptions } from './useParams'
|
|
import type { UseSearchOptions } from './useSearch'
|
|
|
|
export type ValidateLinkOptions<
|
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
TOptions = unknown,
|
|
TDefaultFrom extends string = string,
|
|
TComp = 'a',
|
|
> = Constrain<
|
|
TOptions,
|
|
LinkComponentProps<
|
|
TComp,
|
|
TRouter,
|
|
InferFrom<TOptions, TDefaultFrom>,
|
|
InferTo<TOptions>,
|
|
InferMaskFrom<TOptions>,
|
|
InferMaskTo<TOptions>
|
|
>
|
|
>
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
export type InferStructuralSharing<TOptions> = TOptions extends {
|
|
structuralSharing: infer TStructuralSharing
|
|
}
|
|
? TStructuralSharing
|
|
: unknown
|
|
|
|
export type ValidateUseSearchOptions<
|
|
TOptions,
|
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
> = Constrain<
|
|
TOptions,
|
|
UseSearchOptions<
|
|
TRouter,
|
|
InferFrom<TOptions>,
|
|
InferStrict<TOptions>,
|
|
InferShouldThrow<TOptions>,
|
|
InferSelected<TOptions>,
|
|
InferStructuralSharing<TOptions>
|
|
>
|
|
>
|
|
|
|
export type ValidateUseParamsOptions<
|
|
TOptions,
|
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
> = Constrain<
|
|
TOptions,
|
|
UseParamsOptions<
|
|
TRouter,
|
|
InferFrom<TOptions>,
|
|
InferStrict<TOptions>,
|
|
InferShouldThrow<TOptions>,
|
|
InferSelected<TOptions>,
|
|
InferSelected<TOptions>
|
|
>
|
|
>
|
|
export type ValidateLinkOptionsArray<
|
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
TDefaultFrom extends string = string,
|
|
TComp = 'a',
|
|
> = {
|
|
[K in keyof TOptions]: ValidateLinkOptions<
|
|
TRouter,
|
|
TOptions[K],
|
|
TDefaultFrom,
|
|
TComp
|
|
>
|
|
}
|