Skip to content

Typecheck fails because of virtual:react-router/server-build #13265

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

Closed
stevan-borus opened this issue Mar 19, 2025 · 4 comments
Closed

Typecheck fails because of virtual:react-router/server-build #13265

stevan-borus opened this issue Mar 19, 2025 · 4 comments
Labels

Comments

@stevan-borus
Copy link

I'm using React Router as a...

framework

Reproduction

stackblitz

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 85.94 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 10.5.0 - ~/Library/pnpm/pnpm
    Watchman: 2024.08.26.00 - /opt/homebrew/bin/watchman
Browsers:
    Chrome: 134.0.6998.89
    Edge: 134.0.3124.68
    Safari: 18.3.1
npmPackages:
    @react-router/dev: ^7.4.0 => 7.4.0 
    @react-router/node: ^7.4.0 => 7.4.0 
    react-router: ^7.4.0 => 7.4.0 
    vite: ^6.2.2 => 6.2.2

Used Package Manager

pnpm

Expected Behavior

typecheck should not emit errors tied to virtual:react-router/server-build and react-router in +virtual.ts file

it passes when exactOptionalPropertyTypes is enabled like it's mentioned here but then a lot of different errors pop up throughout the codebase because of exactOptionalPropertyTypes

Actual Behavior

typecheck on v7.4.0 produces these two errors:

.react-router/types/+virtual.ts:1:16 - error TS2664: Invalid module name in augmentation, module 'virtual:react-router/server-build' cannot be found.

declare module "virtual:react-router/server-build" {

.react-router/types/+virtual.ts:2:31 - error TS2307: Cannot find module 'react-router' or its corresponding type declarations.

import { ServerBuild } from "react-router";
@markdalgleish
Copy link
Member

This seems to happen when "moduleDetection": "force" is set in your tsconfig. If this is removed or set to "auto", the error goes away.

I'll see if I can get our typegen'd file to work with this setting enabled.

@markdalgleish
Copy link
Member

Thanks for raising this issue!

This is fixed in #13267 which will be out in the next release.

In the meantime, you can try out this experimental release to confirm that it fixes your issue: 0.0.0-experimental-47c4c03cf

Copy link
Contributor

🤖 Hello there,

We just published version 7.4.1-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.4.1 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants