Skip to content

Commit a963b1a

Browse files
bmiddhaCopilot
authored andcommitted
refactor: use ECMAScript #private methods and accessors
Convert TypeScript private method and getter/setter declarations to native #private syntax across api-documenter, api-extractor, api-extractor-model, credential-cache, debug-certificate-manager, heft-config-file, lookup-by-path, npm-check-fork, operation-graph, package-extractor, stream-collator, terminal, ts-command-line, typings-generator, worker-pool, and doc-plugin-rush-stack, stripping the conventional leading underscore. Extends the prior #private field conversion to methods and accessors using the same symbol-aware tool. Adds an eslint-disable-next-line @rushstack/no-new-null suppression to SourceMapper#getSourceMap, matching the existing suppression on its sibling private field, since converting the method to native #private syntax exposed it to the same decoupled-lint-rule gap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ebd5bf2-c44b-42d5-be25-e7936d4b0a14 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 68fb294 commit a963b1a

44 files changed

Lines changed: 779 additions & 779 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export class ApiDocumenterCommandLine extends CommandLineParser {
1515
'Reads *.api.json files produced by api-extractor, ' +
1616
' and generates API documentation in various output formats.'
1717
});
18-
this._populateActions();
18+
this.#populateActions();
1919
}
2020

21-
private _populateActions(): void {
21+
#populateActions(): void {
2222
this.addAction(new MarkdownAction(this));
2323
this.addAction(new YamlAction(this));
2424
this.addAction(new GenerateAction(this));

apps/api-documenter/src/cli/BaseAction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ export abstract class BaseAction extends CommandLineAction {
7171
}
7272
}
7373

74-
this._applyInheritDoc(apiModel, apiModel);
74+
this.#applyInheritDoc(apiModel, apiModel);
7575

7676
return { apiModel, inputFolder, outputFolder };
7777
}
7878

7979
// TODO: This is a temporary workaround. The long term plan is for API Extractor's DocCommentEnhancer
8080
// to apply all @inheritDoc tags before the .api.json file is written.
8181
// See DocCommentEnhancer._applyInheritDoc() for more info.
82-
private _applyInheritDoc(apiItem: ApiItem, apiModel: ApiModel): void {
82+
#applyInheritDoc(apiItem: ApiItem, apiModel: ApiModel): void {
8383
if (apiItem instanceof ApiDocumentedItem) {
8484
if (apiItem.tsdocComment) {
8585
const inheritDocTag: tsdoc.DocInheritDocTag | undefined = apiItem.tsdocComment.inheritDocTag;
@@ -103,7 +103,7 @@ export abstract class BaseAction extends CommandLineAction {
103103
result.resolvedApiItem.tsdocComment &&
104104
result.resolvedApiItem !== apiItem
105105
) {
106-
this._copyInheritedDocs(apiItem.tsdocComment, result.resolvedApiItem.tsdocComment);
106+
this.#copyInheritedDocs(apiItem.tsdocComment, result.resolvedApiItem.tsdocComment);
107107
}
108108
}
109109
}
@@ -113,7 +113,7 @@ export abstract class BaseAction extends CommandLineAction {
113113
// Recurse members
114114
if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
115115
for (const member of apiItem.members) {
116-
this._applyInheritDoc(member, apiModel);
116+
this.#applyInheritDoc(member, apiModel);
117117
}
118118
}
119119
}
@@ -122,7 +122,7 @@ export abstract class BaseAction extends CommandLineAction {
122122
* Copy the content from `sourceDocComment` to `targetDocComment`.
123123
* This code is borrowed from DocCommentEnhancer as a temporary workaround.
124124
*/
125-
private _copyInheritedDocs(targetDocComment: tsdoc.DocComment, sourceDocComment: tsdoc.DocComment): void {
125+
#copyInheritedDocs(targetDocComment: tsdoc.DocComment, sourceDocComment: tsdoc.DocComment): void {
126126
targetDocComment.summarySection = sourceDocComment.summarySection;
127127
targetDocComment.remarksBlock = sourceDocComment.remarksBlock;
128128

apps/api-documenter/src/documenters/ExperimentalYamlDocumenter.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
2424

2525
this.#tocPointerMap = {};
2626

27-
this._generateTocPointersMap(this.#config.tocConfig);
27+
this.#generateTocPointersMap(this.#config.tocConfig);
2828
}
2929

3030
protected override buildYamlTocFile(apiItems: ReadonlyArray<ApiItem>): IYamlTocFile {
31-
this._buildTocItems2(apiItems);
31+
this.#buildTocItems2(apiItems);
3232
return this.#config.tocConfig;
3333
}
3434

35-
private _buildTocItems2(apiItems: ReadonlyArray<ApiItem>): IYamlTocItem[] {
35+
#buildTocItems2(apiItems: ReadonlyArray<ApiItem>): IYamlTocItem[] {
3636
const tocItems: IYamlTocItem[] = [];
3737
for (const apiItem of apiItems) {
3838
let tocItem: IYamlTocItem;
@@ -52,14 +52,14 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
5252
};
5353

5454
if (apiItem.kind !== ApiItemKind.Package) {
55-
this._filterItem(apiItem, tocItem);
55+
this.#filterItem(apiItem, tocItem);
5656
}
5757
}
5858

5959
tocItems.push(tocItem);
6060

6161
const children: ApiItem[] = this._getLogicalChildren(apiItem);
62-
const childItems: IYamlTocItem[] = this._buildTocItems2(children);
62+
const childItems: IYamlTocItem[] = this.#buildTocItems2(children);
6363
if (childItems.length > 0) {
6464
tocItem.items = childItems;
6565
}
@@ -68,13 +68,13 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
6868
}
6969

7070
// Parses the tocConfig object to build a pointers map of nodes where we want to sort out the API items
71-
private _generateTocPointersMap(tocConfig: IYamlTocFile | IYamlTocItem): void {
71+
#generateTocPointersMap(tocConfig: IYamlTocFile | IYamlTocItem): void {
7272
const { catchAllCategory } = this.#config;
7373

7474
if (tocConfig.items) {
7575
for (const tocItem of tocConfig.items) {
76-
if (tocItem.items && tocItem.items.length > 0 && this._shouldNotIncludeInPointersMap(tocItem)) {
77-
this._generateTocPointersMap(tocItem);
76+
if (tocItem.items && tocItem.items.length > 0 && this.#shouldNotIncludeInPointersMap(tocItem)) {
77+
this.#generateTocPointersMap(tocItem);
7878
} else {
7979
// check for presence of the `catchAllCategory` config option
8080
if (catchAllCategory && tocItem.name === catchAllCategory) {
@@ -90,15 +90,15 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
9090
/**
9191
* Filtering out the api-item by inlineTags or category name presence in the item name.
9292
*/
93-
private _filterItem(apiItem: ApiItem, tocItem: IYamlTocItem): void {
93+
#filterItem(apiItem: ApiItem, tocItem: IYamlTocItem): void {
9494
const { categoryInlineTag, categorizeByName } = this.#config;
9595
const { name: itemName } = tocItem;
9696
let filtered: boolean = false;
9797

9898
// First we attempt to filter by inline tag if provided.
9999
if (apiItem instanceof ApiDocumentedItem) {
100100
const docInlineTag: DocInlineTag | undefined = categoryInlineTag
101-
? this._findInlineTagByName(categoryInlineTag, apiItem.tsdocComment)
101+
? this.#findInlineTagByName(categoryInlineTag, apiItem.tsdocComment)
102102
: undefined;
103103

104104
const tagContent: string | undefined =
@@ -132,7 +132,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
132132

133133
// This is a direct copy of a @docCategory inline tag finder in office-ui-fabric-react,
134134
// but is generic enough to be used for any inline tag
135-
private _findInlineTagByName(
135+
#findInlineTagByName(
136136
tagName: string,
137137
docComment: DocComment | undefined
138138
): DocInlineTag | undefined {
@@ -145,7 +145,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
145145
}
146146
if (docComment) {
147147
for (const childNode of docComment.getChildNodes()) {
148-
const result: DocInlineTag | undefined = this._findInlineTagByName(tagName, childNode as DocComment);
148+
const result: DocInlineTag | undefined = this.#findInlineTagByName(tagName, childNode as DocComment);
149149
if (result !== undefined) {
150150
return result;
151151
}
@@ -154,7 +154,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
154154
return undefined;
155155
}
156156

157-
private _shouldNotIncludeInPointersMap(item: IYamlTocItem): boolean {
157+
#shouldNotIncludeInPointersMap(item: IYamlTocItem): boolean {
158158
const { nonEmptyCategoryNodeNames } = this.#config;
159159
if (nonEmptyCategoryNodeNames && nonEmptyCategoryNodeNames.length) {
160160
return nonEmptyCategoryNodeNames.indexOf(item.name) === -1;

0 commit comments

Comments
 (0)