Skip to content

Fix accessing name on jsdoc link for invalid names - #64032

Merged
Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-jsdoc-link-name-access
Aug 27, 2026
Merged

Fix accessing name on jsdoc link for invalid names#64032
Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-jsdoc-link-name-access

Conversation

Copilot AI commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>[7.0 API] - Accessing name on a jsdoc link that does not have a valid name produces sibling node</issue_title>
<issue_description>### 🔎 Search Terms

jsdoc link name

🕗 Version & Regression Information

  • This changed between versions 6 and 7

⏯ Playground Link

Playground Link

💻 Code

/**
* {@link #toggled} property
*/
export const x = 1;

🙁 Actual behavior

Using the TS API to get the name jsdoc link tag produces node containing JSDocText property (the next sibling node)

import { API } from "@typescript/native-preview/unstable/sync";
import { createVirtualFileSystem } from "@typescript/native-preview/unstable/fs";

const code = `/**
* {@link #toggled} property
*/
export const x = 1;`;

const api = new API({
  fs: createVirtualFileSystem({
    "/tsconfig.json": "{}",
    "/src/sample.ts": code,
  }),
});

const snapshot = api.updateSnapshot({ openProject: "/tsconfig.json" });
const project = snapshot.getProject("/tsconfig.json")!;
const sourceFile = project.program.getSourceFile("/src/sample.ts")!;
const statement = sourceFile.statements[0];

// Should be undefined. Returns `property`
console.log(statement.jsDoc[0].comment[1].name?.getText())

🙂 Expected behavior

The name property of the link should be undefined as in 6.0

import ts from "typescript";

const code = `/**
     * {@link #toggled} property
     */
    export const x = 1;`;

const file = ts.createSourceFile("sample.ts", code, ts.ScriptTarget.Latest, true);
const statement = file.statements[0];

// undefined, since #toggle is  not a valid entity name
console.log(statement.jsDoc[0].comment[1].name?.getText());

Additional information about the issue

No response</issue_description>

Comments on the Issue (you are Copilot in this section)

@andrewbranch

Copy link
Copy Markdown
Member

Copilot what are you doing. no time to waste. hop to it please

Copilot stopped work on behalf of Andrew Branch (andrewbranch) due to an error August 27, 2026 16:50
@andrewbranch

Copy link
Copy Markdown
Member

Copilot yesterday was not your day. today is a new one full of possibility

Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
@andrewbranch
Andrew Branch (andrewbranch) marked this pull request as ready for review August 27, 2026 17:59
Copilot AI balanced review requested due to automatic review settings August 27, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes invalid JSDoc links exposing a sibling node as their name.

Changes:

  • Guard child lookup when a remote node has no children.
  • Add regression coverage for invalid JSDoc link names.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tools/scripts/tsc/generate-encoder.ts Updates generated remote-node logic.
packages/typescript/src/api/node/node.generated.ts Prevents invalid child lookup.
packages/typescript/test/sync/ast.test.ts Adds API regression coverage.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@andrewbranch Andrew Branch (andrewbranch) changed the title [WIP] Fix accessing name on jsdoc link for invalid names Fix accessing name on jsdoc link for invalid names Aug 27, 2026
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Aug 27, 2026
Merged via the queue into main with commit 547fe42 Aug 27, 2026
44 of 47 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the copilot/fix-jsdoc-link-name-access branch August 27, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[7.0 API] - Accessing name on a jsdoc link that does not have a valid name produces sibling node

4 participants