microsoft / microsoft/TypeScript

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.

Aperta
#45,187 3 commenti 19 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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.

🔍 Search Terms

removeComments

✅ 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

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

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’opzione removeComments di tsconfig.json e confronta l’emissione delle dichiarazioni (.d.ts) e del codice sorgente (.js). Determina se opzioni separate o un valore sovraccaricato debbano controllare i commenti in modo indipendente, quindi verifica che il comportamento esistente rimanga invariato e che entrambi i tipi di output possano essere configurati come richiesto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.