question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preserve JSDocs in *.d.ts files when stripping comments

See original GitHub issue

Suggestion/Feature

When using the switch removeComments it will strip out all comments including the ones you may consider useful to the end consumer such as JSDocs. I’d like to strip out any internal comments but preserve any JSDocs comments. It seems that an option to preserve comments in types would be sufficient.

Existing functionality

"removeComments": true,
"declaration": true,

removes all comments including those in *.d.ts files.

Suggested functionality

"removeComments": true,
"declaration": true,

I would think by default you’d want to include the JSDocs in your type defs, so this would remove all comments from the code, but retain any comments associated with the types ie JSDocs.

If however, there is a need to remove all comments then an additional switch may be required to serve that purpose:

"removeCommentsIncludingDeclarations": true,
"declaration": true,

Would produce the same result we have today.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:108
  • Comments:37 (9 by maintainers)

github_iconTop GitHub Comments

41reactions
dotnetprofessionalcommented, Mar 13, 2018

HAPPY ONE YEAR ANNIVERSERY!!!

Its been exactly 1 YEAR today since this was opened. Are we any closer to having this resolved? This doesn’t seem to be a lot of work to fix, but given we’ve had two duplicates since this was opened, it is something people want. I know I’d like to use it on my OSS projects…

36reactions
championswimmercommented, Sep 10, 2018

I’d suggest comments: "never" = no comments comments: "declaration" = comments are put into the .d.ts files comments: "emit" = comments are put into emitted js files

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript strips down comments and spoils JSDoc ...
The compiler preserves docs when there is a direct correspondence between the TS and JS, strictly because there is no harm in doing...
Read more >
Documentation - Creating .d.ts Files from .js files - TypeScript
d.ts files from JavaScript using JSDoc syntax. This set up means you can own the editor experience of TypeScript-powered editors without porting your...
Read more >
JavaScript Programming with Visual Studio Code
ts files. When types cannot be inferred, they can be specified explicitly with JSDoc comments. You can read more about how TypeScript uses...
Read more >
Announcing TypeScript 4.5 - Microsoft Developer Blogs
When deciding which lib files TypeScript should include, ... new flag called --preserveValueImports to prevent TypeScript from stripping out ...
Read more >
Rich Harris on Twitter: "Moved some of my smaller libs to ...
Moved some of my smaller libs to JSDoc TS; thoroughly recommend it. Among other things, the resulting code is generally smaller than transpiled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found