rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Apply @module comments to module namespace objects

Open dmichon-msft opened this issue 3 months ago • 1 comments

Summary

When API-extractor creates a namespace in the API rollup file to represent an exported module namespace object, any @module comment in the source file should be applied to the namespace.

Repro steps

index.ts

export * as Text from './Text';

Text.ts

/**
 * @module
 * Functions for manipulating text.
 */

/**
 * Convert line endings to `\n`
 */
export function convertToLf(input: text): string {
  return text.replace(/\r\n/g, '\n');
}

/**
 * Convert line endings to `\r\n`
 */
export function convertToCrLf(input: text): string {
  return text.replace(/\r?\n/g, '\r\n');
}

Will generate

/**
 * Convert line endings to `\n`
 */
declare function convertToLf(input: text): string;

/**
 * Convert line endings to `\r\n`
 */
declare function convertToCrLf(input: text): string;

declare namespace Text {
  export {
    convertToLf,
    convertToCrLf
  }
}
export { Text }

Details

However, it should generate:

/**
 * Convert line endings to `\n`
 */
declare function convertToLf(input: text): string;

/**
 * Convert line endings to `\r\n`
 */
declare function convertToCrLf(input: text): string;

/**
 * Functions for manipulating text.
 */
declare namespace Text {
  export {
    convertToLf,
    convertToCrLf
  }
}

## Standard questions

Please answer these questions to help us investigate your issue more quickly:

| Question | Answer |
| -------- | -------- |
| `@microsoft/api-extractor` version? | 7.54.0 |
| Operating system? | Linux |
| API Extractor scenario? | rollups (.d.ts) |
| Would you consider contributing a PR? | No |
| TypeScript compiler version? | 5.8.2 |
| Node.js version (`node -v`)? | 22.16.0 |

dmichon-msft avatar Nov 12 '25 19:11 dmichon-msft

@module will need to be added to TSDoc as well.

iclanton avatar Nov 13 '25 22:11 iclanton