File tree Expand file tree Collapse file tree 5 files changed +34
-14
lines changed Expand file tree Collapse file tree 5 files changed +34
-14
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " react-router-dom " : patch
3
+ " react-router " : patch
4
+ " @remix-run/router " : patch
5
+ ---
6
+
7
+ - Fix types for ` RouteObject ` within ` PatchRoutesOnNavigationFunction ` 's ` patch ` method so it doesn't expect agnostic route objects passed to ` patch `
8
+ - Add new ` PatchRoutesOnNavigationFunctionArgs ` type for convenience
Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ export type {
132
132
OutletProps ,
133
133
Params ,
134
134
ParamParseKey ,
135
+ PatchRoutesOnNavigationFunction ,
136
+ PatchRoutesOnNavigationFunctionArgs ,
135
137
Path ,
136
138
PathMatch ,
137
139
Pathname ,
@@ -151,7 +153,6 @@ export type {
151
153
ShouldRevalidateFunctionArgs ,
152
154
To ,
153
155
UIMatch ,
154
- PatchRoutesOnNavigationFunction ,
155
156
} from "react-router" ;
156
157
export {
157
158
AbortedDeferredError ,
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import * as React from "react";
2
2
import type {
3
3
ActionFunction ,
4
4
ActionFunctionArgs ,
5
+ AgnosticPatchRoutesOnNavigationFunction ,
6
+ AgnosticPatchRoutesOnNavigationFunctionArgs ,
5
7
Blocker ,
6
8
BlockerFunction ,
7
9
DataStrategyFunction ,
@@ -32,7 +34,6 @@ import type {
32
34
ShouldRevalidateFunctionArgs ,
33
35
To ,
34
36
UIMatch ,
35
- AgnosticPatchRoutesOnNavigationFunction ,
36
37
} from "@remix-run/router" ;
37
38
import {
38
39
AbortedDeferredError ,
@@ -233,6 +234,12 @@ export {
233
234
useRoutes ,
234
235
} ;
235
236
237
+ export type PatchRoutesOnNavigationFunctionArgs =
238
+ AgnosticPatchRoutesOnNavigationFunctionArgs < RouteObject , RouteMatch > ;
239
+
240
+ export type PatchRoutesOnNavigationFunction =
241
+ AgnosticPatchRoutesOnNavigationFunction < RouteObject , RouteMatch > ;
242
+
236
243
function mapRouteProperties ( route : RouteObject ) {
237
244
let updates : Partial < RouteObject > & { hasErrorBoundary : boolean } = {
238
245
// Note: this check also occurs in createRoutesFromChildren so update
@@ -291,9 +298,6 @@ function mapRouteProperties(route: RouteObject) {
291
298
return updates ;
292
299
}
293
300
294
- export interface PatchRoutesOnNavigationFunction
295
- extends AgnosticPatchRoutesOnNavigationFunction < RouteMatch > { }
296
-
297
301
export function createMemoryRouter (
298
302
routes : RouteObject [ ] ,
299
303
opts ?: {
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ export type {
7
7
AgnosticDataRouteObject ,
8
8
AgnosticIndexRouteObject ,
9
9
AgnosticNonIndexRouteObject ,
10
+ AgnosticPatchRoutesOnNavigationFunction ,
11
+ AgnosticPatchRoutesOnNavigationFunctionArgs ,
10
12
AgnosticRouteMatch ,
11
13
AgnosticRouteObject ,
12
14
DataStrategyFunction ,
@@ -23,7 +25,6 @@ export type {
23
25
LoaderFunctionArgs ,
24
26
ParamParseKey ,
25
27
Params ,
26
- AgnosticPatchRoutesOnNavigationFunction ,
27
28
PathMatch ,
28
29
PathParam ,
29
30
PathPattern ,
Original file line number Diff line number Diff line change @@ -255,15 +255,21 @@ export interface DataStrategyFunction {
255
255
( args : DataStrategyFunctionArgs ) : Promise < Record < string , DataStrategyResult > > ;
256
256
}
257
257
258
- export interface AgnosticPatchRoutesOnNavigationFunction <
258
+ export type AgnosticPatchRoutesOnNavigationFunctionArgs <
259
+ O extends AgnosticRouteObject = AgnosticRouteObject ,
259
260
M extends AgnosticRouteMatch = AgnosticRouteMatch
260
- > {
261
- ( opts : {
262
- path : string ;
263
- matches : M [ ] ;
264
- patch : ( routeId : string | null , children : AgnosticRouteObject [ ] ) => void ;
265
- } ) : void | Promise < void > ;
266
- }
261
+ > = {
262
+ path : string ;
263
+ matches : M [ ] ;
264
+ patch : ( routeId : string | null , children : O [ ] ) => void ;
265
+ } ;
266
+
267
+ export type AgnosticPatchRoutesOnNavigationFunction <
268
+ O extends AgnosticRouteObject = AgnosticRouteObject ,
269
+ M extends AgnosticRouteMatch = AgnosticRouteMatch
270
+ > = (
271
+ opts : AgnosticPatchRoutesOnNavigationFunctionArgs < O , M >
272
+ ) => void | Promise < void > ;
267
273
268
274
/**
269
275
* Function provided by the framework-aware layers to set any framework-specific
You can’t perform that action at this time.
0 commit comments