Skip to content

Commit fb99d92

Browse files
authoredApr 1, 2025··
fix(router-core): remove React type dependency (#3902)
1 parent eab355a commit fb99d92

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed
 

‎packages/react-router/src/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ export type {
125125
FileRoutesByPath,
126126
RouteById,
127127
RootRouteOptions,
128+
SerializerExtensions,
128129
} from '@tanstack/router-core'
129130

131+
export type * from './serializer'
132+
130133
export {
131134
createHistory,
132135
createBrowserHistory,
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type * as React from 'react'
2+
3+
declare module '@tanstack/router-core' {
4+
export interface SerializerExtensions {
5+
ReadableStream: React.JSX.Element
6+
}
7+
}

‎packages/router-core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export type {
7171
SerializerParseBy,
7272
SerializerStringify,
7373
SerializerStringifyBy,
74+
SerializerExtensions,
7475
} from './serializer'
7576

7677
export type { ParsedLocation } from './location'

‎packages/router-core/src/serializer.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ export type SerializerStringifyBy<T, TSerializable> = T extends TSerializable
1313

1414
export type SerializerParseBy<T, TSerializable> = T extends TSerializable
1515
? T
16-
: T extends React.JSX.Element
17-
? ReadableStream
18-
: { [K in keyof T]: SerializerParseBy<T[K], TSerializable> }
16+
: unknown extends SerializerExtensions['ReadableStream']
17+
? { [K in keyof T]: SerializerParseBy<T[K], TSerializable> }
18+
: T extends SerializerExtensions['ReadableStream']
19+
? ReadableStream
20+
: { [K in keyof T]: SerializerParseBy<T[K], TSerializable> }
21+
22+
export interface DefaultSerializerExtensions {
23+
ReadableStream: unknown
24+
}
25+
26+
export interface SerializerExtensions extends DefaultSerializerExtensions {}
1927

2028
export type Serializable = Date | undefined | Error | FormData | bigint
2129

‎packages/solid-router/src/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export type {
206206
ControllablePromise,
207207
InjectedHtmlEntry,
208208
RouterErrorSerializer,
209+
SerializerExtensions,
209210
} from '@tanstack/router-core'
210211

211212
export {

0 commit comments

Comments
 (0)
Please sign in to comment.