angus-c / just

A library of dependency-free JavaScript utilities that do just one thing.
https://anguscroll.com/just
MIT License
6k stars 208 forks source link

Could not find a declaration file for module `just-pipe` #562

Open terrygonguet opened 1 year ago

terrygonguet commented 1 year ago

Hi, thanks, love the packages!

I'm using a pretty basic vite vanilla typescript setup and just-pipe@1.0.0 causes an interesting error:

error TS7016: Could not find a declaration file for module 'just-pipe'. 'C:/Users/.../node_modules/.pnpm/just-pipe@1.0.0/node_modules/just-pipe/index.mjs' implicitly has an 'any' type.
There are types at 'C:/Users/.../node_modules/just-pipe/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'just-pipe' library may need to update its package.json or typings.

The error goes away if I edit just-pipe's package.json to look like just-compose's:

  "exports": {
    ".": {
      "require": "./index.js",
      "default": "./index.mjs",
+     "types": "./index.d.ts"
    }
  },
Here's my tsconfig.json if it helps. ```json5 { "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ES2020", "DOM", "DOM.Iterable"], "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "node16", "allowImportingTsExtensions": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "isolatedModules": true, "declaration": true, "emitDeclarationOnly": true, "outDir": "./types", /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true }, "include": ["src"] } ```

I've always been quite confused about how to specify types in package.json but this one seems like a simple fix.

uncenter commented 11 months ago

Yeah you can see the issue on arethetypeswrong.github.io - looks like quite a few of these packages are published incorrectly. I'll try to make a PR at some point.