dts-generator icon indicating copy to clipboard operation
dts-generator copied to clipboard

Hide private classes

Open wangyan-9067 opened this issue 6 years ago • 3 comments

Is there any way to hide private classes? I would like dts-generator only generate declarations based on index.ts exports, and I don't want my users to see private classes.

wangyan-9067 avatar Nov 01 '18 04:11 wangyan-9067

Not that I'm aware of, but it would be a welcomed improvement.

dylans avatar Nov 05 '18 17:11 dylans

Do you mean some kind of "tree shaking"? In terms of exported types, only the exported types of the given input files, plus all recursively reachable types from those top-level types should be included in output. This is different from considering all exported types from all (recursively) imported modules.

That would be a really great feature! I bundle my package (with esbuild) and have a facade file which exports only those types needed for external users - the public api. Everything else is not reachable anyway via the bundle. The d.ts file should reflect this.

manwithafox avatar Jan 23 '22 22:01 manwithafox

Set up a demo repo which shows the issue: https://github.com/manwithafox/demo-dts-facade

  1. [severe] generated d.ts does NOT contain module address.ts: https://github.com/manwithafox/demo-dts-facade/blob/96a226fa41e306c2f5f319ef446b3817b116cae6/foo.d.ts#L2
  2. [above feature request]
    • generated d.ts contains class B https://github.com/manwithafox/demo-dts-facade/blob/96a226fa41e306c2f5f319ef446b3817b116cae6/foo.d.ts#L8-L10 even it is not reachable via facade.ts
    • private field age should be excluded: https://github.com/manwithafox/demo-dts-facade/blob/96a226fa41e306c2f5f319ef446b3817b116cae6/foo.d.ts#L6

manwithafox avatar Jan 23 '22 22:01 manwithafox