typedoc icon indicating copy to clipboard operation
typedoc copied to clipboard

`declare const` objects with `@enum` tags not included in docs.json

Open ritz078 opened this issue 4 months ago • 1 comments

Search terms

declare const, @enum tag, enum, docs.json, declaration files

Expected Behavior

declare const objects annotated with @enum tags should be documented as enumerations and included in the generated docs.json, per TypeDoc documentation.

Actual Behavior

If we use typeof the enums are not included in JSON

Steps to reproduce the bug

  1. Create src/index.d.ts:
/**
 * This is a declare const with @enum tag - should be included but is NOT
 * @enum
 */
declare const DeclaredEnum: {
  /**
   * First value
   */
  readonly VALUE_A: "valueA",
};

declare namespace X {
  export {
    DeclaredEnum
  }
}

declare const Y: typeof X; // This is causing the issue

export default Y;
  1. Run TypeDoc:
typedoc src/index.d.ts --json docs.json

Result: DeclaredEnum is missing from docs.json

Environment

  • TypeDoc version: 0.28.14
  • TypeScript version: 5.9.3
  • Node.js version: v22.20.0
  • OS: MacOS

ritz078 avatar Nov 19 '25 11:11 ritz078

This seems to be working as intended. The only exported value in your reproduction is Y. TypeDoc documents your exports, not every variable in your source, so TypeDoc only documents default: typeof X.

If you wanted TypeDoc to treat Y as a namespace rather than as a variable simply documented as typeof X then you should add the @namespace tag to Y's documentation comment. If you do that, then DeclaredEnum shows up as a child of the default export namespace.

Gerrit0 avatar Nov 29 '25 03:11 Gerrit0