apollographql / apollographql/apollo-client-integrations
react-router: types fail to resolve on react-router >= 7.7.0 — `react-router/route-module` subpath no longer exists
- Dominant language
- TypeScript
- Stars
- 556
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
`packages/react-router/src/preloader.tsx` imports a type from a react-router subpath that no longer exists:
```ts
import type { CreateServerLoaderArgs } from "react-router/route-module";
```
`./route-module` was removed from react-router's `exports` map during 7.x. It is present in **7.2.0–7.6.0** and absent from **7.7.0 onward, including all of 8.x**:
| react-router | `./route-module` | `./internal` |
|---|---|---|
| 7.2.0 | ✅ | ❌ |
| 7.5.0 | ✅ | ❌ |
| 7.6.0 | ✅ | ❌ |
| 7.7.0 | ❌ | ✅ |
| 7.18.2 | ❌ | ✅ |
| 8.3.0 | ❌ | ✅ |
So on any react-router ≥ 7.7.0, consuming this package's types produces:
```
node_modules/@apollo/client-integration-react-router/dist/index.d.ts(3,40):
error TS2307: Cannot find module 'react-router/route-module'
or its corresponding type declarations.
```
## Why it's easy to miss
The React Router templates set `skipLibCheck: true`, which suppresses TS2307 inside `.d.ts` files. The build stays green — but `CreateServerLoaderArgs` silently resolves to `any`, which removes the constraint from:
```ts
export type ApolloLoader = >() => ...
```
That constraint is the entire point of the two-call `apolloLoader()(loader)` signature the README describes:
> To provide you with better TypeScript support, this is a method that you need to call twice
With `skipLibCheck: false` you get a hard error instead. Either way the advertised typing benefit is gone.
## Note: `react-router/internal` is not a drop-in replacement
The obvious fix doesn't work — `react-router/internal` exports only `GetAnnotations` and `GetInfo`. `CreateServerLoaderArgs` is not re-exported from any public subpath in 8.x; it lives in `lib/types/route-module-annotations.d.ts` as an unexported alias:
```ts
type CreateServerLoaderArgs = ServerDataFunctionArgs;
```
Switching the import would also drop 7.2.0–7.6.0, which are inside the declared `^7.2.0-pre.3` peer range.
PR incoming that removes the dependency on the subpath entirely instead.
## Reproduction
Both apps in https://github.com/thelooter/apollo-rr-loader-repro exhibit this; flip `skipLibCheck` to `false` in either `tsconfig.json` and run `pnpm typecheck`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with packages/react-router/src/preloader.tsx and reproduce the failure by setting skipLibCheck to false in either app from the linked repro, then run pnpm typecheck. Done means the package no longer depends on the missing react-router/route-module subpath and its ApolloLoader type constraint remains effective across the supported React Router versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100