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

fix(58259): getTextOfJSDocComment is stripping # from JSDoc comment #58338

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ export function entityNameToString(name: EntityNameOrEntityNameExpression | JSDo
return Debug.assertNever(name.name);
}
case SyntaxKind.JSDocMemberName:
return entityNameToString(name.left) + entityNameToString(name.right);
return entityNameToString(name.left) + "#" + entityNameToString(name.right);
case SyntaxKind.JsxNamespacedName:
return entityNameToString(name.namespace) + ":" + entityNameToString(name.name);
default:
Expand Down
17 changes: 17 additions & 0 deletions src/testRunner/unittests/jsDocParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,21 @@ oh.no
assert.equal((doc?.jsDoc.tags?.[0] as ts.JSDocTemplateTag).typeParameters.length, 0);
});
});
describe("getTextOfJSDocComment", () => {
it("should preserve hash in string representation of JsDocMemberName", () => {
const sourceText = `
/**
*
* @see {@link foo#bar label}
*/
class Foo {};
`;

const root = ts.createSourceFile("foo.ts", sourceText, ts.ScriptTarget.ES5, /*setParentNodes*/ true);
const [classDecl] = root.statements;
const [seeTag] = ts.getJSDocTags(classDecl);

assert.equal(ts.getTextOfJSDocComment(seeTag.comment), "{@link foo#bar label}");
});
});
});