Skip to content

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions