Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@internal JSDoc tag #522

Open
mary-ext opened this issue Mar 10, 2024 · 2 comments
Open

@internal JSDoc tag #522

mary-ext opened this issue Mar 10, 2024 · 2 comments

Comments

@mary-ext
Copy link

mary-ext commented Mar 10, 2024

TypeScript has an option for stripping away internal-use declarations, stripInternals. It removes exported variables, public fields that are marked with @internal in the doc comments.

Useful in two cases:

  • The need to expose variables, functions for testing, but otherwise undocumented/not meant for public usage
  • Where private fields in classes aren't a choice (need access from outside) and alternatives like WeakMap or declaring a getter function inside a static block seem a little too much.
class Box {
  /** @internal */
  _private: string = 'private string';
}

const box = new Box();
// we can access it, but it won't be documented at all, etc
box._private;

filed as per this Discord message, but perhaps it needs a little more than just on the documentation side? (e.g. JSR needs to strip it too for npm usage, Deno needs to ignore it when it's in an external dependency, etc.)

@crowlKats
Copy link
Member

@mary-ext jsdoc specifies an @ignore tag; would that work for you as well?

@mary-ext
Copy link
Author

mary-ext commented Mar 27, 2024

I think it should, judging by the description of @ignore.
TypeScript only does @internal and it only does so if stripInternal is being used, and @ignore isn't really being stripped out of declarations and all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants