Skip to content

Support stripInternal for types in JSDocΒ #46407

@remcohaszing

Description

@remcohaszing

Suggestion

πŸ” Search Terms

jsdoc internal jsdoc internal stripinternal

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureDomain: Declaration EmitThe issue relates to the emission of d.ts filesDomain: JavaScriptThe issue relates to JavaScript specificallySuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions