Block comment leaks into the line comments before it with `--commentStyle line`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- devtools, documentation
Línea de trabajo
Empieza con collectCommentRanges() en src/lib/converter/comments/discovery.ts y sigue cómo agrupa los rangos de comentarios de una sola línea y de bloque; el issue incluye el bucle pertinente y una reproducción. Comprueba el lexer de comentarios de línea en src/lib/converter/comments/lineLexer.ts para entender cómo se consume el rango. Añade una prueba de regresión para comentarios de línea seguidos de un comentario de bloque con commentStyle: "line"; se considera terminado cuando el comentario de la declaración contiene solo el comentario de línea precedente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Search terms
Line comments followed by a block comment, commentStyle line, coverage pragma, istanbul ignore, garbled comment, collectCommentRanges
Expected Behavior
With --commentStyle line, a declaration takes its comment from the // lines above it, also where a block comment, such as a coverage pragma, sits between those lines and the declaration, since that style reads no block comment.
Actual Behavior
The comment runs on through the block. In the example below, the summary of add is Adds two numbers.\n* istanbul ignore next */. A /** */ block there leaks its tags as well: /** @pattern ^#[0-9a-f]{6}$ */ after a // line adds a tag @pattern whose content ends in */, and TypeDoc warns about an unknown block tag.
The cause is in collectCommentRanges(), which adds every range to the current group of line comments at the top of its loop, before it looks at the range's kind (discovery.ts#L700-L713):
for (const range of ranges || []) {
collect.push(range);
switch (range.kind) {
case ts.SyntaxKind.MultiLineCommentTrivia:
if (collect.length) {
result.push(collect);
collect = [];
}
result.push([range]);
break;
case ts.SyntaxKind.SingleLineCommentTrivia:
collect.push(range);
break;
So a block closes the group of the lines before it as that group's last range, and each line sits in its group twice. With commentStyle: "line", permittedRange() checks only ranges[0].kind, so it takes that group, and lexLineComments() lexes from ranges[0].pos to ranges[ranges.length - 1].end (lineLexer.ts#L10-L15), which is the end of the block.
Steps to reproduce the bug
mkdir repro && cd repro
mkdir src && cat > src/index.ts <<'TS'
// Adds two numbers.
/* istanbul ignore next */
export function add(a: number, b: number): number {
return a + b;
}
TS
echo '{ "include": ["src"] }' > tsconfig.json
npx -y -p [email protected] -p [email protected] typedoc src/index.ts --name repro --commentStyle line --json docs.json
node -p 'JSON.stringify(require("./docs.json").children[0].signatures[0].comment, null, 2)'
{
"summary": [
{
"kind": "text",
"text": "Adds two numbers.\n* istanbul ignore next */"
}
]
}
Would dropping the first collect.push(range); be the fix? With that line deleted from the dist/index.js of 0.28.20, the summary is Adds two numbers. alone. I also ran a file with lines alone, a block alone, a block before lines, lines before a block, lines across a blank line, and two blocks, under each of the styles jsdoc, block, line and all: the output changes only for lines before a block under line. I can open a pull request with a test, if that's welcome.
Environment
- TypeDoc version: 0.28.20
- TypeScript version: 6.0.3
- Node.js version: 24.22.3
- OS: Linux
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.5k
- Forks
- 781
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TypeStrong/typedoc
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
TypeStrong/typedoc#3167 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
TypeStrong/typedoc#3165 ·
-
Variadic tuple element `...T` is rendered as `...T[]` in signatures and membersPosiblemente ocupada @EnesKartal la tomó hace 20 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TypeStrong/typedoc#3157 ·
-
Named rest tuple member loses its `...` (`[a: string, ...rest: boolean[]]` shown as `[a: string, rest: boolean[]]`)Posiblemente ocupada @enidchen0125 la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TypeStrong/typedoc#3154 ·
-
typedoc depends on minimatch 10.x, which is vulnerable to CVE-2026-118764Posiblemente ocupada @fcsondheim la tomó hace 26 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
TypeStrong/typedoc#3150 ·
Todos los issues de TypeStrong/typedoc
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
danielmiessler/LifeOS#3028 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
iOS: last line of a long UITextView text is sometimes not drawn (frame a fraction of a point short)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Koenkk/zigbee2mqtt#33855 ·
Los mantenedores suelen responder en 1 día