|
1 | 1 | /* eslint-disable jest/valid-title */
|
2 | 2 | import type {
|
3 | 3 | ActionFunction,
|
4 |
| - DataRouteObject, |
| 4 | + AgnosticDataRouteObject, |
| 5 | + AgnosticRouteMatch, |
5 | 6 | Fetcher,
|
6 | 7 | RouterFetchOptions,
|
7 | 8 | HydrationState,
|
8 | 9 | InitialEntry,
|
9 | 10 | LoaderFunction,
|
10 |
| - RouteMatch, |
11 | 11 | Router,
|
12 | 12 | RouterNavigateOptions,
|
13 | 13 | StaticHandler,
|
@@ -37,7 +37,7 @@ import { TrackedPromise } from "../utils";
|
37 | 37 | // Routes passed into setup() should just have a boolean for loader/action
|
38 | 38 | // indicating they want a stub
|
39 | 39 | type TestRouteObject = Pick<
|
40 |
| - DataRouteObject, |
| 40 | + AgnosticDataRouteObject, |
41 | 41 | "id" | "index" | "path" | "shouldRevalidate"
|
42 | 42 | > & {
|
43 | 43 | loader?: boolean;
|
@@ -411,7 +411,7 @@ function setup({
|
411 | 411 | }
|
412 | 412 |
|
413 | 413 | function getHelpers(
|
414 |
| - matches: RouteMatch<string, DataRouteObject>[], |
| 414 | + matches: AgnosticRouteMatch<string, AgnosticDataRouteObject>[], |
415 | 415 | navigationId: number,
|
416 | 416 | addHelpers: (routeId: string, helpers: InternalHelpers) => void
|
417 | 417 | ): Record<string, Helpers> {
|
@@ -495,15 +495,14 @@ function setup({
|
495 | 495 | // @ts-expect-error
|
496 | 496 | if (opts?.formMethod === "post") {
|
497 | 497 | if (currentRouter.state.navigation?.location) {
|
498 |
| - activeLoaderMatches = matchRoutes( |
| 498 | + let matches = matchRoutes( |
499 | 499 | enhancedRoutes,
|
500 | 500 | currentRouter.state.navigation.location
|
501 |
| - ) as RouteMatch<string, EnhancedRouteObject>[]; |
| 501 | + ); |
| 502 | + invariant(matches, "No matches found for fetcher"); |
| 503 | + activeLoaderMatches = matches; |
502 | 504 | } else {
|
503 |
| - activeLoaderMatches = currentRouter.state.matches as RouteMatch< |
504 |
| - string, |
505 |
| - EnhancedRouteObject |
506 |
| - >[]; |
| 505 | + activeLoaderMatches = currentRouter.state.matches; |
507 | 506 | }
|
508 | 507 | }
|
509 | 508 |
|
|
0 commit comments