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 {
132132 OutletProps ,
133133 Params ,
134134 ParamParseKey ,
135+ PatchRoutesOnNavigationFunction ,
136+ PatchRoutesOnNavigationFunctionArgs ,
135137 Path ,
136138 PathMatch ,
137139 Pathname ,
@@ -151,7 +153,6 @@ export type {
151153 ShouldRevalidateFunctionArgs ,
152154 To ,
153155 UIMatch ,
154- PatchRoutesOnNavigationFunction ,
155156} from "react-router" ;
156157export {
157158 AbortedDeferredError ,
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import * as React from "react";
22import type {
33 ActionFunction ,
44 ActionFunctionArgs ,
5+ AgnosticPatchRoutesOnNavigationFunction ,
6+ AgnosticPatchRoutesOnNavigationFunctionArgs ,
57 Blocker ,
68 BlockerFunction ,
79 DataStrategyFunction ,
@@ -32,7 +34,6 @@ import type {
3234 ShouldRevalidateFunctionArgs ,
3335 To ,
3436 UIMatch ,
35- AgnosticPatchRoutesOnNavigationFunction ,
3637} from "@remix-run/router" ;
3738import {
3839 AbortedDeferredError ,
@@ -233,6 +234,12 @@ export {
233234 useRoutes ,
234235} ;
235236
237+ export type PatchRoutesOnNavigationFunctionArgs =
238+ AgnosticPatchRoutesOnNavigationFunctionArgs < RouteObject , RouteMatch > ;
239+
240+ export type PatchRoutesOnNavigationFunction =
241+ AgnosticPatchRoutesOnNavigationFunction < RouteObject , RouteMatch > ;
242+
236243function mapRouteProperties ( route : RouteObject ) {
237244 let updates : Partial < RouteObject > & { hasErrorBoundary : boolean } = {
238245 // Note: this check also occurs in createRoutesFromChildren so update
@@ -291,9 +298,6 @@ function mapRouteProperties(route: RouteObject) {
291298 return updates ;
292299}
293300
294- export interface PatchRoutesOnNavigationFunction
295- extends AgnosticPatchRoutesOnNavigationFunction < RouteMatch > { }
296-
297301export function createMemoryRouter (
298302 routes : RouteObject [ ] ,
299303 opts ?: {
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ export type {
77 AgnosticDataRouteObject ,
88 AgnosticIndexRouteObject ,
99 AgnosticNonIndexRouteObject ,
10+ AgnosticPatchRoutesOnNavigationFunction ,
11+ AgnosticPatchRoutesOnNavigationFunctionArgs ,
1012 AgnosticRouteMatch ,
1113 AgnosticRouteObject ,
1214 DataStrategyFunction ,
@@ -23,7 +25,6 @@ export type {
2325 LoaderFunctionArgs ,
2426 ParamParseKey ,
2527 Params ,
26- AgnosticPatchRoutesOnNavigationFunction ,
2728 PathMatch ,
2829 PathParam ,
2930 PathPattern ,
Original file line number Diff line number Diff line change @@ -255,15 +255,21 @@ export interface DataStrategyFunction {
255255 ( args : DataStrategyFunctionArgs ) : Promise < Record < string , DataStrategyResult > > ;
256256}
257257
258- export interface AgnosticPatchRoutesOnNavigationFunction <
258+ export type AgnosticPatchRoutesOnNavigationFunctionArgs <
259+ O extends AgnosticRouteObject = AgnosticRouteObject ,
259260 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 > ;
267273
268274/**
269275 * Function provided by the framework-aware layers to set any framework-specific
You can’t perform that action at this time.
0 commit comments