Skip to content

Middleware types not working with NodeNext resolution #13375

@pawelblaszczyk5

Description

@pawelblaszczyk5

I'm using React Router as a...

framework

Reproduction

https://github.com/pawelblaszczyk5/invalid-new-middleware-types-node-next

  1. Go to app/routes/home.tsx
  2. Observe context being typed incorrectly despite middleware being enabled and global type augmentation done

Image

Image

I think that's similar cause as this - #12715

If you change the module resolution to e.g. Bundler it will work properly.

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 406.81 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.local/state/fnm_multishells/3848_1743953207334/bin/node
    Yarn: 1.22.19 - ~/.local/state/fnm_multishells/3848_1743953207334/bin/yarn
    npm: 10.2.3 - ~/.local/state/fnm_multishells/3848_1743953207334/bin/npm
    pnpm: 8.15.8 - ~/.local/state/fnm_multishells/3848_1743953207334/bin/pnpm
    bun: 1.1.33 - ~/.bun/bin/bun
  Browsers:
    Chrome: 134.0.6998.166
    Edge: 120.0.2210.121
    Safari: 18.3.1
  npmPackages:
    @react-router/dev: ^7.5.0 => 7.5.0 
    @react-router/node: ^7.5.0 => 7.5.0 
    @react-router/serve: ^7.5.0 => 7.5.0 
    react-router: ^7.5.0 => 7.5.0 
    vite: ^5.4.11 => 5.4.17

Used Package Manager

pnpm

Expected Behavior

context parameter is properly typed due to augmentation in react-router.config.ts

Actual Behavior

context is incorrectly typed (still AppLoadContext) when using NodeNext

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions