Rich-Harris / dts-buddy

WORK IN PROGRESS DO NOT USE
MIT License
321 stars 12 forks source link

Support auto-inferred index files #79

Open Juice10 opened 7 months ago

Juice10 commented 7 months ago

In rrweb we are using directories with an index.ts file inside them and importing them in the following manner:

import { replay } from './replay';

In typescript this autocompletes to ./replay/index.*.

Unfortunately dts-buddy gives the following error whenever an import like this gets encountered:

yarn dts-buddy dist/index.d.ts -m rrweb:dist/rrweb.js -m rrweb-replay:dist/rrweb-replay.js
yarn run v1.23.0-20220130.1630
$ /Users/justin/repos/rrweb-monorepo/node_modules/.bin/dts-buddy dist/index.d.ts -m rrweb:dist/rrweb.js -m rrweb-replay:dist/rrweb-replay.js
node:internal/fs/sync:25
  return binding.readFileUtf8(path, stringToFlags(flag));
                 ^

Error: ENOENT: no such file or directory, open '/Users/justin/repos/rrweb-monorepo/packages/rrweb/dist/replay.d.ts'
    at Object.readFileUtf8 (node:internal/fs/sync:25:18)
    at Object.readFileSync (node:fs:441:19)
    at get_dts (file:///Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/src/utils.js:184:34)
    at create_module_declaration (file:///Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/src/create-module-declaration.js:59:19)
    at createBundle (file:///Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/src/index.js:228:43)
    at file:///Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/src/cli.js:75:9
    at o.parse (/Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/node_modules/sade/lib/index.js:1:3402)
    at file:///Users/justin/repos/rrweb-monorepo/node_modules/dts-buddy/src/cli.js:86:9
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/justin/repos/rrweb-monorepo/packages/rrweb/dist/replay.d.ts'
}
mstade commented 1 month ago

Hi @Juice10! I'm running into this when setting "strict": true in my jsconfig.json, but not when it's set to false. Where you ever able to resolve this?

Juice10 commented 1 month ago

@mstade unfortunately not I ended up switching out dts-buddy for another project