Block comment leaks into the line comments before it with `--commentStyle line`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- devtools, documentation
Direzione di ricerca
Inizia da collectCommentRanges() in src/lib/converter/comments/discovery.ts e segui il modo in cui raggruppa gli intervalli dei commenti su una singola riga e dei commenti di blocco; l’issue include il ciclo pertinente e una riproduzione. Controlla il lexer dei commenti di riga in src/lib/converter/comments/lineLexer.ts per capire come viene consumato l’intervallo. Aggiungi un test di regressione per i commenti di riga seguiti da un commento di blocco con commentStyle: "line"; il lavoro è completato quando il commento della dichiarazione contiene solo il commento di riga precedente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 8.5k
- Fork
- 781
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TypeStrong/typedoc
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
TypeStrong/typedoc#3167 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
TypeStrong/typedoc#3165 ·
-
Variadic tuple element `...T` is rendered as `...T[]` in signatures and membersForse già presa @EnesKartal l’ha presa 20 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TypeStrong/typedoc#3157 ·
-
Named rest tuple member loses its `...` (`[a: string, ...rest: boolean[]]` shown as `[a: string, rest: boolean[]]`)Forse già presa @enidchen0125 l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TypeStrong/typedoc#3154 ·
-
typedoc depends on minimatch 10.x, which is vulnerable to CVE-2026-118764Forse già presa @fcsondheim l’ha presa 26 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TypeStrong/typedoc#3150 ·
Tutte le issue di TypeStrong/typedoc
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
danielmiessler/LifeOS#3028 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
iOS: last line of a long UITextView text is sometimes not drawn (frame a fraction of a point short)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
Koenkk/zigbee2mqtt#33855 ·
I maintainer di solito rispondono entro 1 giorno