From d465486168e233596afe278256397ac23fb23727 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sat, 27 Apr 2024 03:04:16 +0300 Subject: [PATCH] fix(58259): should preserve hash in string representation of JsDocMemberName --- src/compiler/utilities.ts | 2 +- src/testRunner/unittests/jsDocParsing.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a2426b253cc3d..9211b5c9e1710 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -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: diff --git a/src/testRunner/unittests/jsDocParsing.ts b/src/testRunner/unittests/jsDocParsing.ts index 0635aff6cdd1d..02f5c8e199980 100644 --- a/src/testRunner/unittests/jsDocParsing.ts +++ b/src/testRunner/unittests/jsDocParsing.ts @@ -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}"); + }); + }); });