Skip to content

[api-extractor] Surface whether a class member is protected #3386

@zelliott

Description

@zelliott

Summary

Consider the following class:

class Example {
  protected name: string;
  protected constructor(name: string) {
    this.name = name;
  }
  protected doThing(): void {}
}

In all three of the types of members above (i.e. property, method, constructor), class members can be marked as protected. This information isn't included in the .api.json file in a structured way (besides the protected keyword existing in the item's excerptTokens field).

We should expose an isProtected property on the ApiProperty, ApiMethod, and ApiConstructor items. We can do this by adding a new ApiProtectedMixin mixin (or ApiVisibilityMixin?) that functions similarly to the existing ApiStaticMixin.

Details

N/A

Standard questions

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

Question Answer
@microsoft/api-extractor version? Latest
Operating system? All
API Extractor scenario? docs
Would you consider contributing a PR? Yes
TypeScript compiler version? N/A
Node.js version (node -v)? N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue is asking for a new feature or design change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions