Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTextOfJSDocComment introduces a space in JSDoc comments #58584

Closed
JeanMeche opened this issue May 20, 2024 · 0 comments · Fixed by #58585
Closed

getTextOfJSDocComment introduces a space in JSDoc comments #58584

JeanMeche opened this issue May 20, 2024 · 0 comments · Fixed by #58585

Comments

@JeanMeche
Copy link
Contributor

JeanMeche commented May 20, 2024

🔎 Search Terms

getJSDocTags
getTextOfJSDocComment

🕗 Version & Regression Information

5.5.0-beta and previous.

⏯ Playground Link

https://stackblitz.com/edit/gettextofjsdoccomment-dbm6rj?file=main.ts,package.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) => {
      console.log('> ', ts.getTextOfJSDocComment(tag.comment));
    });
  }
};

ts.forEachChild(sourceFile, visitNode);

🙁 Actual behavior

getTextOfJSDocComment returns {@link entry }. Notice the trailing space.

🙂 Expected behavior

getTextOfJSDocComment should return {@link entry}, without introducing a space.

Additional information about the issue

No response

JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
JeanMeche added a commit to JeanMeche/TypeScript that referenced this issue May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant