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.

Abierto
#45,187 3 comentarios 19 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, typescript
Área
compilers

Línea de trabajo

Comienza con la opción removeComments de tsconfig.json y compara la emisión de declaraciones (.d.ts) y código fuente (.js). Determina si opciones separadas o un valor sobrecargado deberían controlar los comentarios de forma independiente y, a continuación, verifica que el comportamiento existente no cambie y que ambos tipos de salida se puedan configurar como se solicita.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Awaiting More Feedback Suggestion

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.

Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/TypeScript

Todos los issues de microsoft/TypeScript

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.