Skip to content

[api-extractor] Doc Model always trims internal and alpha methods #5258

@SBLMikeDemone

Description

@SBLMikeDemone

Summary

I'm trying to get a doc model (.api.json) to report all APIs: internal, alpha, beta, and public. By specifying "releaseTagsToTrim": []" config option in the doc model I can get most internal APIs to show up EXCEPT methods on classes.

Repro steps

  1. Set up an extremely barebones project based on this template: https://api-extractor.com/pages/setup/invoking/
  2. Set up index.ts:
/**
 * @public
 */
export class PublicClass {
    /**
     * @internal
     */
    internalMethod() {
    }
}

/**
 * @internal
 */
export function internalFunction() {
}
  1. Set up api-extractor.json with the default template and replace docModel with:
"docModel": {
    "enabled": true,
    "releaseTagsToTrim": []
}
  1. Run the api-extractor with api-extractor run --local
  2. Observe the generated doc model (temp/awesome-widgets.api.json)

Expected result:
The doc model reports the existence of PublicClass.internalMethod and internalFunction.

Actual result:
The doc model does not report the existence of PublicClass.internalMethod but it does report the existence of internalFunction.

Details

Diving into the code, it looks like there's a hardcoded if statement for methods that breaks early for internal and alpha and doesn't report them. See here: https://github.com/microsoft/rushstack/blob/main/apps/api-extractor/src/generators/ApiModelGenerator.ts#L770-L772

      if (releaseTag === ReleaseTag.Internal || releaseTag === ReleaseTag.Alpha) {
        return; // trim out items marked as "@internal" or "@alpha"
      }

I believe the solution is to just delete that if check because the check of the api tag against releaseTagsToTrim in _processDeclaration should cover this case.

Standard questions

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

Question Answer
@microsoft/api-extractor version? 7.52.8
Operating system? Windows
API Extractor scenario? docs (.api.json)
Would you consider contributing a PR? Yes
TypeScript compiler version? 5.8.2
Node.js version (node -v)? 22.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions