Skip to content

Commit 7072126

Browse files
committed
Fix types in router test file
1 parent 9908786 commit 7072126

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/router/__tests__/router-test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable jest/valid-title */
22
import type {
33
ActionFunction,
4-
DataRouteObject,
4+
AgnosticDataRouteObject,
5+
AgnosticRouteMatch,
56
Fetcher,
67
RouterFetchOptions,
78
HydrationState,
89
InitialEntry,
910
LoaderFunction,
10-
RouteMatch,
1111
Router,
1212
RouterNavigateOptions,
1313
StaticHandler,
@@ -37,7 +37,7 @@ import { TrackedPromise } from "../utils";
3737
// Routes passed into setup() should just have a boolean for loader/action
3838
// indicating they want a stub
3939
type TestRouteObject = Pick<
40-
DataRouteObject,
40+
AgnosticDataRouteObject,
4141
"id" | "index" | "path" | "shouldRevalidate"
4242
> & {
4343
loader?: boolean;
@@ -411,7 +411,7 @@ function setup({
411411
}
412412

413413
function getHelpers(
414-
matches: RouteMatch<string, DataRouteObject>[],
414+
matches: AgnosticRouteMatch<string, AgnosticDataRouteObject>[],
415415
navigationId: number,
416416
addHelpers: (routeId: string, helpers: InternalHelpers) => void
417417
): Record<string, Helpers> {
@@ -495,15 +495,14 @@ function setup({
495495
// @ts-expect-error
496496
if (opts?.formMethod === "post") {
497497
if (currentRouter.state.navigation?.location) {
498-
activeLoaderMatches = matchRoutes(
498+
let matches = matchRoutes(
499499
enhancedRoutes,
500500
currentRouter.state.navigation.location
501-
) as RouteMatch<string, EnhancedRouteObject>[];
501+
);
502+
invariant(matches, "No matches found for fetcher");
503+
activeLoaderMatches = matches;
502504
} else {
503-
activeLoaderMatches = currentRouter.state.matches as RouteMatch<
504-
string,
505-
EnhancedRouteObject
506-
>[];
505+
activeLoaderMatches = currentRouter.state.matches;
507506
}
508507
}
509508

packages/router/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export interface AgnosticDataRouteMatch
231231
extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {}
232232

233233
// Walk the route tree generating unique IDs where necessary so we are working
234-
// solely with DataRouteObject's within the Router
234+
// solely with AgnosticDataRouteObject's within the Router
235235
export function convertRoutesToDataRoutes(
236236
routes: AgnosticRouteObject[],
237237
parentPath: number[] = [],

0 commit comments

Comments
 (0)