Skip to content

AppLoadContext in typegen files isn't correctly augmented when using NodeNext module resolution #12715

Closed

Description

@pawelblaszczyk5

I'm using React Router as a...

framework

Reproduction

This was previously reported as a part of #12424 Since that one is already resolved I wanted to separate this part into its own issue, so it can be tracked.

Reproduction - I separated reproduction into separate commit

  1. Go to app/routes/home.tsx
  2. Observe mismatch between context from typegen file and context imported from react-router

System Info

Not applicable here, but here you go:

  System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 195.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.local/state/fnm_multishells/18617_1736447107271/bin/node
    Yarn: 1.22.19 - ~/.local/state/fnm_multishells/18617_1736447107271/bin/yarn
    npm: 10.2.3 - ~/.local/state/fnm_multishells/18617_1736447107271/bin/npm
    pnpm: 8.15.8 - ~/.local/state/fnm_multishells/18617_1736447107271/bin/pnpm
    bun: 1.1.33 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.205
    Edge: 120.0.2210.121
    Safari: 18.1.1
  npmPackages:
    @react-router/dev: ^7.1.1 => 7.1.1 
    @react-router/node: ^7.1.1 => 7.1.1 
    @react-router/serve: ^7.1.1 => 7.1.1 
    react-router: ^7.1.1 => 7.1.1 
    vite: ^5.4.11 => 5.4.11

Used Package Manager

pnpm

Expected Behavior

When I augment AppLoadContext types I expect them to work also in types coming from typegen files

Actual Behavior

There's a mismatch between AppLoadContext in type gen file and imported from react-router one:

image

Activity

  1. Mordred commented on Jan 21, 2025

    @Mordred

    I'm also experiencing this issue. I solved it for now with explicit typing:

    export const loader = ({ context }: Route.LoaderArgs & { context: AppLoadContext }) => {
      ...
    }
    
  2. self-assigned this
    on Apr 29, 2025
  3. pcattori commented on Apr 29, 2025

    @pcattori
    Contributor

    Fixed by #13498 , should be available next release

  4. github-actions commented on May 8, 2025

    @github-actions
    Contributor

    🤖 Hello there,

    We just published version 7.6.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!

  5. github-actions commented on May 25, 2025

    @github-actions
    Contributor

    🤖 Hello there,

    We just published version 7.6.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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions