microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.57k stars 12.43k forks source link

Support stripInternal for types in JSDoc #46407

Open remcohaszing opened 2 years ago

remcohaszing commented 2 years ago

Suggestion

🔍 Search Terms

jsdoc internal jsdoc internal stripinternal

✅ Viability Checklist

My suggestion meets these guidelines:

⭐ Suggestion

Currently, if "stripInternal": true is set in the compiler options, the @internal JSDoc annotation can be used to prevent it from ending up in the generated type definitions.

When using types in JSDoc, a type can be defined using:

/**
 * @typedef {object} MyType
 * Description of `MyType`.
 */

It would be great of @internal could also be applied to types in JSDoc.

📃 Motivating Example

The @internal annotation now also works for types defined in JSDoc if the "stripInternal" option is enabled.

/**
 * @typedef {object} MyType
 * @internal
 */

💻 Use Cases

These typedefs are always exported, but often they are only defined to import a type. This means that packages often need to add a dependency on packages only for their types, even if the intention isn’t to re-export them.

/**
 * @typedef {import('my-package').MyType} MyType
 * @internal
 */

A lot of practical use cases exist in the unified ecosystem.

For example remark-rehype.

swingingtom commented 2 years ago

@remcohaszing Did you succeed to have it working?

remcohaszing commented 2 years ago

No. It’s a feature request. The feature doesn’t exist (yet).

swingingtom commented 2 years ago

I was confused by the subtask status of this issue...