Skip to content

[@react-router/dev/vite] typecheck fails when skipLibCheck: false and moduleResolution: nodenext #13457

Open
@AviVahl

Description

@AviVahl

I'm using React Router as a...

framework

Reproduction

mkdir react-router-dev-type-issue
cd react-router-dev-type-issue
npm init -y
npm i typescript react-router @react-router/dev
npx tsc --init --moduleResolution nodenext --module nodenext --skipLibCheck false
echo "import '@react-router/dev/vite';" > index.ts
npx tsc --noEmit

yields:

node_modules/@react-router/dev/dist/vite.d.ts:5:36 - error TS2503: Cannot find namespace 'Vite'.

5 type ReactRouterVitePlugin = () => Vite.Plugin[];
                                     ~~~~

This also happens when importing @react-router/dev/config', as it uses Vite's resolution options interface as well.

System Info

Irrelevant. Type-issue that happens on all systems.

Used Package Manager

npm

Expected Behavior

Pass with all typescript modern resolution modes, not only 'bundler'.

Actual Behavior

@react-router/dev is not marked as "type": "module", so *.d.ts files are treated as commonjs in this mode.
The import to Vite therefor receives the deprecated cjs version of vite's runtime/types (separate .d.ts that says "any").

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions