Repository: TypeScript
Issue: tsconfig.json option removeComments removes comments from both declaration.d.ts and source .js files, it would be convenient to only remove comments from .js files.
Labels: Suggestion,Awaiting More Feedback

# Suggestion

The TypeScript tsconfig.json `removeComments` removes all comments from both declaration and source files. It would be convenient to be able to specify `removeCommentsFromDeclaration` (.d.ts) and `removeCommentsFromModule` (.js) independently.

<!--
  Please fill in each section completely. Thank you!
-->

## 🔍 Search Terms

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

removeComments

## ✅ Viability Checklist

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).


## ⭐ Suggestion

Source .js files are used directly when importing packages and do not need comments as these can contribute to the size. 

It is often undesirable to show off internal comments, especially when developing external libraries.

Declaration `.d.ts` files are used for IntelliSense and it is usually desired for them to have comments, api-extractor uses generated  declarations for documentation extraction.

While there are work arounds, they require running additional commands instead of getting everything in one go.

Provide `removeCommentsFromDeclaration` (.d.ts) and `removeCommentsFromModule` (.js) options alongside the existing `removeComments` __OR__ allow `removeComments` to be overloaded to have `["declaration", "module"]` to specify the specific comments to remove.

## 📃 Motivating Example

Remove comments from .js to:

- reduce size of the package when uploaded to NPM and downloaded from NPM
- reduce size of packages on disk
- reduce size of imports without post processing
- hide internal package comments from external developers

## 💻 Use Cases

<!--
  What do you want to use this for?
  What shortcomings exist with current approaches?
  What workarounds are you using in the meantime?
-->

The workaround is to have the .d.ts and .js be potentially out of sync by running two separate commands to generate the .d.ts and .js files.