Skip to content
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

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

Open
pawelblaszczyk5 opened this issue Jan 9, 2025 · 1 comment
Labels

Comments

@pawelblaszczyk5
Copy link

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

@Mordred
Copy link

Mordred commented Jan 21, 2025

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

export const loader = ({ context }: Route.LoaderArgs & { context: AppLoadContext }) => {
  ...
}

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