-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
{@link Class.name}
resolves wrongly to Function.name
#61433
Comments
The correct syntax to refer to that is |
The hash notation is not working in TypeScript. The dot notation instead, seem to work fine, TypeScript just resolves https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250215#code/MYGwhgzhAEAqCmEAu0DeBYAUNH0D0AVAVrjgdABLwggD2JpBeDOAdmALbwBcyATgEtWAc2gBeaACIEySVgC+WLIWLZyqAAIghAaziIkAYnZdFa6CXKWLa5pgBmAV1bAkA2q2hgAFEm4ykAEo0Fmg+eCRHPk8kADoTeABuBSA It seems the TSDoc spec has this point still in discussion. |
When I ctrl-click on |
Now as you say it, something seems off. Generally I was triggered by the following behaviors that something is broken:
https://stackblitz.com/edit/vitejs-vite-7bzn4y19?file=src%2Ftest.ts&terminal=dev I moved to the dot notation in my docs to provide a better developer experience when devs use my library.
I could extend my code to use From a low level AST behavior:
While JSDoc seem to promote I currently have this (ugly/hacky) workaround in place when using the Compiler API if (comment.name.getText().endsWith(".name")) {
// resolve parent
if (ts.isQualifiedName(comment.name)) {
symbol = context.checker.getSymbolAtLocation(
comment.name.left
);
} else if (ts.isJSDocMemberName(comment.name)) {
symbol = context.checker.getSymbolAtLocation(
comment.name.left
);
}
symbol = symbol?.members?.get(
ts.escapeLeadingUnderscores("name")
);
} else {
symbol = context.checker.getSymbolAtLocation(comment.name);
} Edit: I perpared a stackblitz reproduction to look at the situation (execute with https://stackblitz.com/edit/vitejs-vite-pnhqv3jq?file=compiler.ts |
π Search Terms
JSDoc, TSDoc, Link, Resolve, Name
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250215#code/MYGwhgzhAEAqCmEAu0DeBYAUNH0D0AVAVrjgdABLwggD2JpBeDOAdmALbwBcyATgEtWAc2gBeaACIEySVgC+WLIWLZyqAAIghAaziIkAOnZdFa5pgBmAV1bAkA2q2hgAFEm4ykASjQtofPBI1nzORibwANwKQA
π» Code
π Actual behavior
The
Test.name
reference in the JSDoc/TSDoc resolves to the symbolFunction.name
. This is not correct because theTest
class has an own property declaration forname
.In my real world usecase am generating markdowns from my typescript code via TypeScript compiler API and I get the wrong symbol using
typeChecker.getSymbolAtLocation(tsDocLinkNode.name)
leading to wrong documentation links.π Expected behavior
The correct documentation of my
name
property should be shown.The typeChecker should resolve this expression to the correct symbol to allow tooling to resolve these cross references and link to the respective documentation page.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: