Skip to content

Commit 7e6fecc

Browse files
committed
Fix type issues
1 parent 34a0c45 commit 7e6fecc

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"typescript.enablePromptUseWorkspaceTsdk": true
3+
"typescript.enablePromptUseWorkspaceTsdk": true,
4+
"cSpell.words": ["otherhost"]
45
}

packages/react-router/__tests__/dom/data-browser-router-test.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
} from "@testing-library/react";
88
import * as React from "react";
99
import type {
10-
RouteObject,
1110
ErrorResponse,
1211
Fetcher,
13-
RouterState,
12+
Location,
1413
Navigation,
14+
RouteObject,
1515
} from "../../index";
1616
import {
1717
Await,
@@ -37,10 +37,9 @@ import {
3737
useSearchParams,
3838
useSubmit,
3939
} from "../../index";
40-
40+
import { createDeferred, tick } from "../router/utils/utils";
4141
import getHtml from "../utils/getHtml";
4242
import getWindow from "../utils/getWindow";
43-
import { createDeferred, tick } from "../router/utils/utils";
4443

4544
testDomRouter("<DataBrowserRouter>", createBrowserRouter, (url) =>
4645
getWindow(url, false),
@@ -482,7 +481,7 @@ function testDomRouter(
482481
`);
483482
});
484483

485-
it("does not render fallbackElement if no data fetch or lazy loading is required", async () => {
484+
it("does not render hydrateFallback if no data fetch or lazy loading is required", async () => {
486485
let fooDefer = createDeferred();
487486
let router = createTestRouter(
488487
[
@@ -6997,7 +6996,11 @@ function testDomRouter(
69976996
{ window: getWindow("/") },
69986997
);
69996998

7000-
function FetcherComponent({ onClose }) {
6999+
function FetcherComponent({
7000+
onClose,
7001+
}: {
7002+
onClose: (data: any) => void;
7003+
}) {
70017004
let fetcher = useFetcher();
70027005

70037006
React.useEffect(() => {
@@ -7544,7 +7547,7 @@ function testDomRouter(
75447547
});
75457548

75467549
it("renders hydration errors on lazy leaf elements with preloading", async () => {
7547-
let routes = [
7550+
let routes: RouteObject[] = [
75487551
{
75497552
path: "/",
75507553
Component: () => <Comp />,
@@ -7567,7 +7570,7 @@ function testDomRouter(
75677570
if (lazyMatches && lazyMatches?.length > 0) {
75687571
await Promise.all(
75697572
lazyMatches.map(async (m) => {
7570-
let routeModule = await m.route.lazy!();
7573+
let routeModule = await (m.route.lazy as Function)();
75717574
Object.assign(m.route, { ...routeModule, lazy: undefined });
75727575
}),
75737576
);
@@ -7675,7 +7678,7 @@ function testDomRouter(
76757678
});
76767679

76777680
it("renders hydration errors on lazy parent elements with preloading", async () => {
7678-
let routes = [
7681+
let routes: RouteObject[] = [
76797682
{
76807683
path: "/",
76817684
lazy: async () => ({
@@ -7693,7 +7696,7 @@ function testDomRouter(
76937696
if (lazyMatches && lazyMatches?.length > 0) {
76947697
await Promise.all(
76957698
lazyMatches.map(async (m) => {
7696-
let routeModule = await m.route.lazy!();
7699+
let routeModule = await (m.route.lazy as Function)();
76977700
Object.assign(m.route, { ...routeModule, lazy: undefined });
76987701
}),
76997702
);
@@ -8213,7 +8216,7 @@ function testDomRouter(
82138216
};
82148217
};
82158218

8216-
let renders: RouterState[] = [];
8219+
let renders: [Location, Navigation][] = [];
82178220
let router = createTestRouter(
82188221
[
82198222
{
@@ -8236,7 +8239,7 @@ function testDomRouter(
82368239
return "INDEX";
82378240
},
82388241
Component() {
8239-
renders.push(useLocation(), useNavigation());
8242+
renders.push([useLocation(), useNavigation()]);
82408243
return <h1>{useLoaderData()}</h1>;
82418244
},
82428245
},
@@ -8247,7 +8250,7 @@ function testDomRouter(
82478250
return "PAGE";
82488251
},
82498252
Component() {
8250-
renders.push(useLocation(), useNavigation());
8253+
renders.push([useLocation(), useNavigation()]);
82518254
return <h1>{useLoaderData()}</h1>;
82528255
},
82538256
},
@@ -8265,14 +8268,15 @@ function testDomRouter(
82658268

82668269
expect(renders).toMatchObject([
82678270
// Re-render of current location with navigation.state = "loading"
8268-
{ pathname: "/" },
8269-
{
8270-
state: "loading",
8271-
location: { pathname: "/page" },
8272-
},
8271+
[
8272+
{ pathname: "/" },
8273+
{
8274+
state: "loading",
8275+
location: { pathname: "/page" },
8276+
},
8277+
],
82738278
// Render of new location with navigation.state = "idle"
8274-
{ pathname: "/page" },
8275-
{ state: "idle" },
8279+
[{ pathname: "/page" }, { state: "idle" }],
82768280
]);
82778281
});
82788282
});

0 commit comments

Comments
 (0)