Microsoft/TypeScript

`getTextOfJSDocComment` introduces a space in JSDoc comments

Open

#59.679 geöffnet am 19. Aug. 2024

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: JSDocHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

🔎 Search Terms

getJSDocTags getTextOfJSDocComment

🕗 Version & Regression Information

Tested on 5.5.4, also existed on previous versions.

⏯ Playground Link

https://stackblitz.com/edit/gettextofjsdoccomment-dbm6rj?file=main.ts,package-lock.json

💻 Code

import ts from 'typescript';

const filename = 'example.ts';
const code = `
/** 
 * 
 * @see {@link entry()}
 */
class Foo  {};
`;

const sourceFile = ts.createSourceFile(
  filename,
  code,
  ts.ScriptTarget.ESNext,
  true
);

const visitNode = (node: ts.Node) => {
  ts.forEachChild(node, visitNode);
  const tags = ts.getJSDocTags(node);
  if (tags.length) {
    tags.forEach((tag) => {
      const comment = tag.comment!.slice(1) as any;

      console.log(
        tag.tagName.getText(),
        '> ',
        ts.getTextOfJSDocComment(comment)
      );

      //console.log(comment);
    });
  }
};

ts.forEachChild(sourceFile, visitNode);

🙁 Actual behavior

getTextOfJSDocComment returns {@link entry ()}. Notice the space inbetween.

🙂 Expected behavior

getTextOfJSDocComment returns {@link entry()}. Notice the space inbetween.

Additional information about the issue

This is a variation of #58584.

Also noticed it happened with {@link core/inject} becoming {@link core /inject}

Contributor Guide