Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

TSDocEmitter 0.17.0 drops the line break before a code span or {@link}, joining words

Aperta Adatta ai principianti
#493 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
documentation

Direzione di ricerca

Inizia da TrimSpacesTransform.pushAccumulatedText() ed esegui la riproduzione fornita di TSDocEmitter per gli spezzoni di codice, i link e il testo semplice. Il lavoro è completato quando viene preservata un’interruzione di riga morbida prima di un nodo inline non testuale, senza modificare la gestione prevista delle interruzioni tra parole normali o dopo i nodi inline.

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

Descrizione

Summary

Since 0.17.0 ("Update emitter to not replace line breaks"), TSDocEmitter drops a soft break that sits immediately before an inline non-text node (code span, {@link}, HTML element), and emits no space in its place. The two words end up joined.

API Extractor 7.59.2 (which moved to @microsoft/tsdoc ~0.17.0) writes this output into the docComment field of .api.json models, so every downstream consumer of the model (documenters, generated indexes) receives the damaged text.

Repro

const t = require("@microsoft/tsdoc");
const cases = {
  code: "/**\n * policy is\n * `\"fail\"`.\n */",
  link: "/**\n * see the\n * {@link Foo} thing.\n */",
  plain: "/**\n * policy is\n * fail now.\n */",
  codeMid: "/**\n * a `x`\n * then b.\n */",
};
for (const [k, src] of Object.entries(cases)) {
  const sb = new t.StringBuilder();
  new t.TSDocEmitter().renderComment(sb, new t.TSDocParser().parseString(src).docComment);
  console.log(k, JSON.stringify(sb.toString()));
}
Case 0.16.0 0.17.0
break before code span policy is `"fail"`. policy is`"fail"`.
break before {@link} see the {@link Foo} thing. see the{@link Foo} thing.
break between plain words policy is fail now. policy is\n * fail now. (preserved, as intended)
break after code span a `x` then b. a `x`\n * then b. (preserved, as intended)

Cause

TrimSpacesTransform.pushAccumulatedText() splits the accumulated text on \n and only emits a DocSoftBreak ahead of a non-empty line. When the accumulated text ends in a soft break ("policy is\n"), the split yields a trailing empty line; it is skipped, and with it the soft break. The default branch then pushes the inline node straight after the text. Before 0.17.0 the soft break was rendered as a space, which masked this.

Suggested fix

In pushAccumulatedText(), when the final line is empty and i !== 0 (the text ended in a line break), still push a DocSoftBreak so the following inline node starts on a new line.

Environment

  • @microsoft/tsdoc 0.17.0 (0.16.0 is correct)
  • @microsoft/api-extractor 7.59.2 / @microsoft/api-extractor-model 7.33.13
  • Node 26
Lingua principale
TypeScript
Stelle
5k
Fork
162
Merge medio
17h 4m
PR unite (30g)
7

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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.

Altre issue di microsoft/tsdoc

Tutte le issue di microsoft/tsdoc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.