parcel icon indicating copy to clipboard operation
parcel copied to clipboard

Have the @parcel/transformer-typescript-types ignore methods mark with /** @internal */

Open koenbollen opened this issue 3 years ago • 1 comments

🙋 feature request

Have the @parcel/transformer-typescript-types package ignore classes, methods, etc. that are marked as /** @internal */.

🤔 Expected Behavior

When a method is marked as @internal I expect it to be omitted from the resulting types.d.ts

😯 Current Behavior

There is currently no way for me to skip something when generating type definition files.

💁 Possible Solution

The collect.js file could detect the @internal tag on symbols and skip them.

🔦 Context

I'm creating a typescript library and I want to export the type definitions but when I do that with Parcel it includes all kinds of internal types and classes because I have some 'public' methods on public classes that are only used internally (I mark those methods with an underscore prefix). If I (for the test) remove those methods the extra internal types/classes are neatly omitted.

💻 Examples

This is an example of an internal method: peer.ts#L227. It's prefixed with an underscore to note that users of the library should not use it (typescript doesnt have an 'internal' access modifier). When I add the "types" directive to the package.json and build the project I get a netlib.d.ts file exporting including all the subtypes that are used by the argument of this internal method. I would love if I could annotate that method somehow and that then the package @parcel/transformer-typescript-types skips it.

koenbollen avatar Jul 27 '22 13:07 koenbollen

I could possibly make a pull-request if needed. 👍🏻

koenbollen avatar Jul 27 '22 13:07 koenbollen

Isn't this basically solved by setting stripInternal to true in tsconfig.json?

suzukieng avatar Feb 08 '23 09:02 suzukieng

hey! sorry for the late reply. We finally go to testing stripInternal: true and that is exactly what we needed. 👍🏻 Thanks! Closing the issue now.

koenbollen avatar Jul 12 '23 09:07 koenbollen