remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
28.95k stars 2.45k forks source link

The inferred type of 'loader' cannot be named without a reference to #9714

Open vixalien opened 2 months ago

vixalien commented 2 months ago

Reproduction

Install packages with pnpm

Try using the new defineLoader from unstable fetch.

make sure to add

    "types": [
      "@remix-run/react/future/single-fetch.d.ts"
    ]

to tsconfig.json

System Info

System:
    OS: Linux 6.9 Alpine Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 23.21 GB / 31.06 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 22.1.0 - ~/.nvm/versions/node/v22.1.0/bin/node
    Yarn: 1.22.22 - ~/.local/share/pnpm/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v22.1.0/bin/npm
    pnpm: 9.4.0 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @remix-run/dev: ^2.10.2 => 2.10.2 
    @remix-run/eslint-config: ^2.10.2 => 2.10.2 
    @remix-run/node: ^2.10.2 => 2.10.2 
    @remix-run/react: ^2.10.2 => 2.10.2 
    @remix-run/serve: ^2.10.2 => 2.10.2 
    vite: ^5.2.11 => 5.3.3

Used Package Manager

pnpm

Expected Behavior

The code to work correctly

Actual Behavior

I get the following typescript errors:

The inferred type of 'loader' cannot be named without a reference to '.pnpm/@remix-run+server-runtime@2.10.2_typescript@5.5.3/node_modules/@remix-run/server-runtime/dist/single-fetch'. This is likely not portable. A type annotation is necessary.ts(2742)

The inferred type of 'loader' cannot be named without a reference to '.pnpm/react-router@6.24.1_react@19.0.0-rc-f994737d14-20240522/node_modules/react-router'. This is likely not portable. A type annotation is necessary.ts(2742)

This may be due to pnpm's strict dependencies isolation.

jansedlon commented 1 month ago

Yes this happens to me as well.

PS: btw @vixalien you said you use npm but i can see .pnpm in the errors

vixalien commented 1 month ago

You're right. That's a mistake from my side