Skip to content

Commit f2ebc7c

Browse files
bmiddhaCopilot
andcommitted
refactor: convert overloaded private methods to #private
Manually inspect the 9 tool-skipped candidates from the private member conversion. Getter/setter and method-overload declarations that share a TypeScript symbol are known false positives in the symbol-aware codemod: it flags every overload signature as an 'unsupported reference' to every other overload of the same method. For AmazonS3Client's '_makeSignedRequestAsync' (3 overload signatures) and HttpBuildCacheProvider's '_tryGetCredentialsAsync' (4 overload signatures + implementation), a repo-wide search found only ordinary same-class 'this.method(...)' call sites -- no bracket access, 'as any' casts, reflection, prototype tricks, or test spies. Converted every overload declaration and call site to '#makeSignedRequestAsync' / '#tryGetCredentialsAsync'. Left PlaywrightBrowserTunnel's 'status' accessor pair (public getter / private setter) as TS-private: this is not a false positive. Native ECMAScript private accessors have no way to make only the setter private while the getter of the same name stays public -- '#status' would need to be a single accessor pair with uniform visibility, and it would collide with the existing '#status' backing field. Converting it would require restructuring the field name, which is outside the scope of a straightforward private-to-# conversion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ebd5bf2-c44b-42d5-be25-e7936d4b0a14
1 parent 0167cd7 commit f2ebc7c

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

rush-plugins/rush-amazon-s3-build-cache-plugin/src/AmazonS3Client.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class AmazonS3Client {
153153
public async getObjectAsync(objectName: string): Promise<Buffer | undefined> {
154154
this.#writeDebugLine('Reading object from S3');
155155
return await this.#sendCacheRequestWithRetriesAsync(async () => {
156-
const response: IWebClientResponse = await this._makeSignedRequestAsync('GET', objectName);
156+
const response: IWebClientResponse = await this.#makeSignedRequestAsync('GET', objectName);
157157
return this.#handleGetResponseAsync(response, async () => await response.getBufferAsync());
158158
});
159159
}
@@ -164,7 +164,7 @@ export class AmazonS3Client {
164164
}
165165

166166
await this.#sendCacheRequestWithRetriesAsync(async () => {
167-
const response: IWebClientResponse = await this._makeSignedRequestAsync(
167+
const response: IWebClientResponse = await this.#makeSignedRequestAsync(
168168
'PUT',
169169
objectName,
170170
objectBuffer
@@ -191,7 +191,7 @@ export class AmazonS3Client {
191191
public async downloadObjectToFileAsync(objectName: string, localFilePath: string): Promise<boolean> {
192192
this.#writeDebugLine('Downloading object from S3 to file');
193193
const result: boolean | undefined = await this.#sendCacheRequestWithRetriesAsync(async () => {
194-
const response: IWebClientStreamResponse = await this._makeSignedRequestAsync(
194+
const response: IWebClientStreamResponse = await this.#makeSignedRequestAsync(
195195
'GET',
196196
objectName,
197197
undefined,
@@ -229,7 +229,7 @@ export class AmazonS3Client {
229229
const entryStream: FileSystemReadStream = FileSystem.createReadStream(localFilePath);
230230

231231
// Streaming uploads cannot be retried because the stream is consumed after the first attempt.
232-
const response: IWebClientStreamResponse = await this._makeSignedRequestAsync(
232+
const response: IWebClientStreamResponse = await this.#makeSignedRequestAsync(
233233
'PUT',
234234
objectName,
235235
entryStream as Readable,
@@ -318,20 +318,20 @@ export class AmazonS3Client {
318318
return new Error(`Amazon S3 responded with status code ${status} (${statusText})`);
319319
}
320320

321-
private async _makeSignedRequestAsync(
321+
async #makeSignedRequestAsync(
322322
verb: 'GET' | 'PUT',
323323
objectName: string,
324324
body?: Buffer
325325
): Promise<IWebClientResponse>;
326-
private async _makeSignedRequestAsync(
326+
async #makeSignedRequestAsync(
327327
verb: 'GET' | 'PUT',
328328
objectName: string,
329329
body: Readable | undefined,
330330
stream: true,
331331
contentHash?: string,
332332
contentLength?: number
333333
): Promise<IWebClientStreamResponse>;
334-
private async _makeSignedRequestAsync(
334+
async #makeSignedRequestAsync(
335335
verb: 'GET' | 'PUT',
336336
objectName: string,
337337
body?: Buffer | Readable,

rush-plugins/rush-http-build-cache-plugin/src/HttpBuildCacheProvider.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
405405
stream
406406
} = options;
407407
const safeCredentialOptions: CredentialsOptions = credentialOptions ?? CredentialsOptions.Optional;
408-
const credentials: string | undefined = await this._tryGetCredentialsAsync(safeCredentialOptions);
408+
const credentials: string | undefined = await this.#tryGetCredentialsAsync(safeCredentialOptions);
409409
const url: string = new URL(relUrl, this.#url).href;
410410

411411
const headers: Record<string, string> = {};
@@ -489,11 +489,11 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
489489
return response;
490490
}
491491

492-
private async _tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;
493-
private async _tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;
494-
private async _tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;
495-
private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;
496-
private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {
492+
async #tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;
493+
async #tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;
494+
async #tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;
495+
async #tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;
496+
async #tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {
497497
if (options === CredentialsOptions.Omit) {
498498
return;
499499
}

0 commit comments

Comments
 (0)