Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/react-start/basic-auth/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/basic-react-query/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/basic-tsr-config/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/custom-basepath/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/query-integration/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/scroll-restoration/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/selective-ssr/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import type { getRouter } from './router.tsx'
import type { startInstance } from './start.tsx'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
config: Awaited<ReturnType<typeof startInstance.getOptions>>
}
Expand Down
1 change: 1 addition & 0 deletions e2e/react-start/server-functions/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/server-routes/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/spa-mode/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/virtual-routes/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/react-start/website/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/custom-basepath/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/scroll-restoration/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/selective-ssr/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/server-functions/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/server-routes/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/spa-mode/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions e2e/solid-start/website/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-bare/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-basic-auth/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-basic-static/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ import type { getRouter } from './router.tsx'
import type { startInstance } from './start.tsx'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
config: Awaited<ReturnType<typeof startInstance.getOptions>>
}
Expand Down
1 change: 1 addition & 0 deletions examples/react/start-convex-trellaux/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-counter/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-large/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-material-ui/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-supabase-basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-tailwind-v4/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-trellaux/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/react/start-workos/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/solid/start-bare/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/solid/start-basic-static/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
1 change: 1 addition & 0 deletions examples/solid/start-basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
6 changes: 6 additions & 0 deletions packages/router-core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ export interface Register {
// ssr
}

export type RegisteredSsr<TRegister = Register> = TRegister extends {
ssr: infer TSSR
}
? TSSR
: false

export type RegisteredRouter<TRegister = Register> = TRegister extends {
router: infer TRouter
}
Expand Down
27 changes: 16 additions & 11 deletions packages/router-core/src/ssr/serializer/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { createPlugin } from 'seroval'
import { GLOBAL_TSR } from '../constants'
import type { Plugin, SerovalNode } from 'seroval'
import type { RegisteredConfigType, SSROption } from '../../router'
import type {
RegisteredConfigType,
RegisteredSsr,
SSROption,
} from '../../router'
import type { LooseReturnType } from '../../utils'
import type { AnyRoute, ResolveAllSSR } from '../../route'

Expand Down Expand Up @@ -194,16 +198,17 @@ export type ValidateSerializableLifecycleResult<
TParentRoute extends AnyRoute,
TSSR,
TFn,
> = false extends (TRegister extends { ssr: infer TSSR } ? TSSR : never)
? any
: ValidateSerializableLifecycleResultSSR<
TRegister,
TParentRoute,
TSSR,
TFn
> extends infer TInput
? TInput
: never
> =
false extends RegisteredSsr<TRegister>
? any
: ValidateSerializableLifecycleResultSSR<
TRegister,
TParentRoute,
TSSR,
TFn
> extends infer TInput
? TInput
: never

export type ValidateSerializableLifecycleResultSSR<
TRegister,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function moduleDeclaration({
result.push(
`declare module '@tanstack/${corePluginOpts.framework}-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>`,
)
if (startFilePath) {
Expand Down
Loading