`declare const` objects with `@enum` tags not included in docs.json
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
- 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;
- 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
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.