Skip to content

Commit 0b7db2f

Browse files
fix: check return type of router.dehydrate w.r.t. serializability (#5057)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 5f1a1c7 commit 0b7db2f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/router-core/src/router.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type {
4646
} from '@tanstack/history'
4747
import type {
4848
Awaitable,
49+
Constrain,
4950
ControlledPromise,
5051
NoInfer,
5152
NonNullableUpdater,
@@ -84,7 +85,10 @@ import type { Manifest } from './manifest'
8485
import type { AnySchema, AnyValidator } from './validators'
8586
import type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
8687
import type { NotFoundError } from './not-found'
87-
import type { AnySerializationAdapter } from './ssr/serializer/transformer'
88+
import type {
89+
AnySerializationAdapter,
90+
ValidateSerializableInput,
91+
} from './ssr/serializer/transformer'
8892
import type { AnyRouterConfig } from './config'
8993

9094
export type ControllablePromise<T = any> = Promise<T> & {
@@ -122,7 +126,7 @@ export interface RouterOptions<
122126
TTrailingSlashOption extends TrailingSlashOption,
123127
TDefaultStructuralSharingOption extends boolean = false,
124128
TRouterHistory extends RouterHistory = RouterHistory,
125-
TDehydrated extends Record<string, any> = Record<string, any>,
129+
TDehydrated = undefined,
126130
> extends RouterOptionsExtensions {
127131
/**
128132
* The history object that will be used to manage the browser history.
@@ -290,7 +294,10 @@ export interface RouterOptions<
290294
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
291295
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
292296
*/
293-
dehydrate?: () => Awaitable<TDehydrated>
297+
dehydrate?: () => Constrain<
298+
TDehydrated,
299+
ValidateSerializableInput<Register, TDehydrated>
300+
>
294301
/**
295302
* A function that will be called when the router is hydrated.
296303
*

0 commit comments

Comments
 (0)