isaacs / rimraf

A `rm -rf` util for nodejs
ISC License
5.62k stars 250 forks source link

Missing types for glob dependency #286

Closed paulsmithkc closed 12 months ago

paulsmithkc commented 12 months ago

Using rimraf@5.0.1 I am getting the following typescript error:

node_modules/rimraf/dist/mjs/index.d.ts:2:29 - error TS7016: Could not find a declaration file for module 'glob'. '---/node_modules/glob/glob.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/glob` if it exists or add a new declaration (.d.ts) file containing `declare module 'glob';`

2 import { GlobOptions } from 'glob';
                              ~~~~~~

Found 1 error in node_modules/rimraf/dist/mjs/index.d.ts:2
paulsmithkc commented 12 months ago

Workaround, pin the glob version:

npm install glob@10.3.6
isaacs commented 12 months ago

Actual fix for this: enable resolvePackageJsonExports.

Glob just stopped exporting incorrect types for its commonjs build. You have to tell typescript that your node version supports exports and so it should, too. I recommend "module": "node16" or "module": "nodeNext" in your tsconfig.

A similar change will be made in rimraf shortly.

paulsmithkc commented 11 months ago

Related to https://github.com/isaacs/node-glob/issues/557