sannajammeh / trpc-swr

tRPC-ified SWR hooks
https://trpc-swr.vercel.app
MIT License
209 stars 5 forks source link

Can't import trpc-swr/infinite types #11

Closed Yovach closed 2 years ago

Yovach commented 2 years ago

Hi, I can't import import { getUseSWRInfinite } from 'trpc-swr/infinite' because it's seems invalid.

My project is a Next.js project with this tsconfig.json :

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "paths": {
      "~libs/*": ["src/libs/*"],
      "~components/*": ["src/components/*"],
      "~styles/*": ["src/styles/*"],
      "~server/*": ["src/server/*"]
    }
  },
  "include": ["next-env.d.ts", "./src/**/*.ts", "./src/**/*.tsx"],
  "exclude": ["node_modules"]
}

When I set moduleResolution to node16, trpc-swr/infinite is detected and can be imported but an error appears : Could not find a declaration file for module trpc-swr.

NPM Version : 8.11.0 Node Version : 16.15.1 Next.js version : 12.2.2 trpc-swr version: 0.1.3

Thanks !

EDIT: I can also import trpc-swr/infinite with trpc-swr/dist/infinite

sachinraja commented 2 years ago

Ah I think the issue here is that the infinite directory is not being published. That directory is essentially a proxy for the dist files to satisfy TypeScript.

Yovach commented 2 years ago

I can run my Next.js with npm run dev so yes it's definitely TypeScript related. I tried to solve this but I don't know enough about publishing packages..

sachinraja commented 2 years ago

I'll fix it later today and do a publish

sachinraja commented 2 years ago

fixed in v0.1.5

Yovach commented 2 years ago

Oh, thank you!