1

Running tsc with --declaration option generates the .d.ts file with all the declaration, private included.

Is there a way to produce a .d.ts file with only exported types and, for classes, only public methods and attributes?

Daniele Ricci
  • 15,422
  • 1
  • 27
  • 55

1 Answers1

5

It's not possible.

Typescript keeps privates in generated .d.ts files to support further inheritance.

Because there is no such thing as 'private' in JS, declaring a type that derives from a d.ts type with stripped out privates could cause problems if you accidentally will have a name collision in your child class. That will be very difficult to find and fix.

Yuriy Naydenov
  • 1,875
  • 1
  • 13
  • 31