remix icon indicating copy to clipboard operation
remix copied to clipboard

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

Open vixalien opened this issue 1 year ago • 2 comments

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/@[email protected][email protected]/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/[email protected][email protected]/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.

vixalien avatar Jul 05 '24 01:07 vixalien

Yes this happens to me as well.

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

jansedlon avatar Jul 17 '24 05:07 jansedlon

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

vixalien avatar Jul 17 '24 12:07 vixalien

Single-fetch types setup has changed. See https://github.com/remix-run/remix/blob/main/CHANGELOG.md#improved-single-fetch-type-safety-unstable

pcattori avatar Sep 18 '24 02:09 pcattori