Preserve JSDocs in *.d.ts files when stripping comments
See original GitHub issueSuggestion/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:
- Created 7 years ago
- Reactions:108
- Comments:37 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
I’d suggest
comments: "never"
= no commentscomments: "declaration"
= comments are put into the .d.ts filescomments: "emit"
= comments are put into emitted js files