Skip to content

fix(react-router): remove Navigator TS declaration override #13512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-tools-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

Remove `Navigator` declaration for `navigator.connection.saveData` to avoid messing with any other types beyond `saveData` in userland
9 changes: 2 additions & 7 deletions packages/react-router/lib/dom/ssr/fog-of-war.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import type { EntryRoute } from "./routes";
import { createClientRoutes } from "./routes";
import type { ServerBuild } from "../../server-runtime/build";

declare global {
interface Navigator {
connection?: { saveData: boolean };
}
}

// Currently rendered links that may need prefetching
const nextPaths = new Set<string>();

Expand Down Expand Up @@ -115,7 +109,8 @@ export function useFogOFWarDiscovery(
// Don't prefetch if not enabled or if the user has `saveData` enabled
if (
!isFogOfWarEnabled(routeDiscovery, ssr) ||
navigator.connection?.saveData === true
// @ts-expect-error - TS doesn't know about this yet
window.navigator?.connection?.saveData === true
) {
return;
}
Expand Down