Skip to content

Typegen fails to resolve .mdx files #13954

@nikolailehbrink

Description

@nikolailehbrink

Reproduction

https://stackblitz.com/edit/github-pvha4jzr-ionx6pm8

  1. Run the typegen command with pnpm typecheck and see the errors regarding the "mdx" file.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @react-router/dev: ^7.6.3 => 7.6.3 
    @react-router/node: 7.6.3 => 7.6.3 
    @react-router/serve: ^7.6.3 => 7.6.3 
    react-router: ^7.6.3 => 7.6.3 
    vite: ^6.3.3 => 6.3.5

Used Package Manager

pnpm

Expected Behavior

When running type generation in a project with MDX routes, the generated +types/*.ts files reference the .mdx files directly:

type Module = typeof import("../home.mdx")

This causes TypeScript errors:

.react-router/types/app/routes/+types/home.ts:5:29 - error TS2307: Cannot find module '../home.mdx' or its corresponding type declarations.

Actual Behavior

No errors should be shown, because it is working properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions