timocov / dts-bundle-generator

A tool to generate a single bundle of dts with types tree-shaking
MIT License
744 stars 38 forks source link

Reading declarations of undefined #329

Closed EinfachLeo closed 2 weeks ago

EinfachLeo commented 1 month ago

Bug report

Hi!

When I try to run the generator, I get an error Cannot read properties of undefined (reading 'declarations') (it happens both locally and in the Github job)

I took the time to get the proper stacktrace, but I am none the wiser.

TypeError: Cannot read properties of undefined (reading 'declarations')
    at getDeclarationsForSymbol ([...]/node_modules/dts-bundle-generator/dist/helpers/typescript.js:114:16)
    at TypesUsageEvaluator.computeUsageForNode ([...]/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:115:93)
    at visitNodes ([...]/node_modules/typescript/lib/typescript.js:31715:22)
    at forEachChildInSourceFile ([...]/node_modules/typescript/lib/typescript.js:31928:12)
    at Object.forEachChild ([...]/node_modules/typescript/lib/typescript.js:32228:35)
    at TypesUsageEvaluator.computeUsages ([...]/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:58:12)
    at new TypesUsageEvaluator ([...]/node_modules/dts-bundle-generator/dist/types-usage-evaluator.js:11:12)
    at generateDtsBundle ([...]/node_modules/dts-bundle-generator/dist/bundle-generator.js:20:31)
    at main ([...]/node_modules/dts-bundle-generator/dist/bin/dts-bundle-generator.js:193:67)
    at measureTime ([...]/node_modules/dts-bundle-generator/dist/helpers/measure-time.js:10:5)

Additional context The entire command chain I ran is rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && copyfiles ./package.json build. The config file looks like this:

const config = {
  entries: [
    {
      filePath: './src/index.ts',
      outFile: './build/dist/index.d.ts',
      noCheck: false,
    },
  ],
};

module.exports = config;
aryaemami59 commented 4 weeks ago

Having the exact same issue. Did you figure out a solution yet?

timocov commented 3 weeks ago

Can you share the repro for this issue?

aryaemami59 commented 3 weeks ago

@EinfachLeo I'm pretty sure it was the types field in tsconfig.json that was causing the issue. Does your problem go away if you remove it or just set it to an empty array?

timocov commented 3 weeks ago

Does your problem go away if you remove it or just set it to an empty array?

@aryaemami59 is this question for @EinfachLeo ?

aryaemami59 commented 3 weeks ago

@timocov Yes my apologies.

EinfachLeo commented 2 weeks ago

@aryaemami59 Seems to go away, yes