react-docgen-typescript icon indicating copy to clipboard operation
react-docgen-typescript copied to clipboard

@link in description broken if target can be resolved

Open kryops opened this issue 5 months ago • 0 comments

Hi there,

when parsing JSDoc @link annotations with a link text set, the parser removes the space between the link target and the link text if the link's target can be resolved:

const MyOtherComponent = () => {};

/**
 * My component. Similar to
 * - {@link MyOtherComponent other component}.
 * - {@link MyOtherComponent|other component}.
 * - {@link MyOtherComponent2 other component 2}.
 * - {@link MyOtherComponent2|other component 2}.
 */
export const Foo = () => <div>...</div>;

Output:

description: 'My component. Similar to\n' +
      '- {@link MyOtherComponentother component}.\n' +
      '- {@link MyOtherComponentother component}.\n' +
      '- {@link MyOtherComponent2 other component 2}.\n' +
      '- {@link MyOtherComponent2 other component 2}.',

Expected:

description: 'My component. Similar to\n' +
      '- {@link MyOtherComponent other component}.\n' +
      '- {@link MyOtherComponent other component}.\n' +
      '- {@link MyOtherComponent2 other component 2}.\n' +
      '- {@link MyOtherComponent2 other component 2}.',

Thanks for looking into it!

kryops avatar Sep 08 '25 12:09 kryops