Adopt prefer-readonly in JS/TS extension (#165089)

This commit is contained in:
Matt Bierner
2022-11-14 20:12:10 -08:00
committed by GitHub
parent 9ccc7e3627
commit 44441de137
12 changed files with 36 additions and 20 deletions

View File

@@ -16,10 +16,11 @@ export interface IExperimentationTelemetryReporter extends tas.IExperimentationT
* but will only do so when passed to an {@link ExperimentationService}.
*/
export class ExperimentationTelemetryReporter
implements IExperimentationTelemetryReporter {
export class ExperimentationTelemetryReporter implements IExperimentationTelemetryReporter {
private _sharedProperties: Record<string, string> = {};
private _reporter: VsCodeTelemetryReporter;
private readonly _reporter: VsCodeTelemetryReporter;
constructor(reporter: VsCodeTelemetryReporter) {
this._reporter = reporter;
}

View File

@@ -13,8 +13,8 @@ interface ExperimentTypes {
}
export class ExperimentationService {
private _experimentationServicePromise: Promise<tas.IExperimentationService>;
private _telemetryReporter: IExperimentationTelemetryReporter;
private readonly _experimentationServicePromise: Promise<tas.IExperimentationService>;
private readonly _telemetryReporter: IExperimentationTelemetryReporter;
constructor(telemetryReporter: IExperimentationTelemetryReporter, id: string, version: string, globalState: vscode.Memento) {
this._telemetryReporter = telemetryReporter;

View File

@@ -36,7 +36,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensP
public constructor(
protected client: ITypeScriptServiceClient,
private cachedResponse: CachedResponse<Proto.NavTreeResponse>
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>
) { }

View File

@@ -37,7 +37,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider
public constructor(
private readonly client: ITypeScriptServiceClient,
private cachedResponse: CachedResponse<Proto.NavTreeResponse>,
private readonly cachedResponse: CachedResponse<Proto.NavTreeResponse>,
) { }
public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentSymbol[] | undefined> {

View File

@@ -185,7 +185,7 @@ class SourceAddMissingImports extends SourceAction {
class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
private static kindProviders = [
private static readonly kindProviders = [
SourceFixAll,
SourceRemoveUnused,
SourceAddMissingImports,

View File

@@ -1,3 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as ts from 'typescript/lib/tsserverlibrary';
export = ts.server.protocol;

View File

@@ -34,9 +34,9 @@ export class WorkerServerProcess implements TsServerProcess {
]);
}
private _onDataHandlers = new Set<(data: Proto.Response) => void>();
private _onErrorHandlers = new Set<(err: Error) => void>();
private _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>();
private readonly _onDataHandlers = new Set<(data: Proto.Response) => void>();
private readonly _onErrorHandlers = new Set<(err: Error) => void>();
private readonly _onExitHandlers = new Set<(code: number | null, signal: string | null) => void>();
public constructor(
private readonly worker: Worker,

View File

@@ -99,9 +99,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
private readonly workspaceState: vscode.Memento;
private _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void };
private readonly _onReady?: { promise: Promise<void>; resolve: () => void; reject: () => void };
private _configuration: TypeScriptServiceConfiguration;
private pluginPathsProvider: TypeScriptPluginPathsProvider;
private readonly pluginPathsProvider: TypeScriptPluginPathsProvider;
private readonly _versionManager: TypeScriptVersionManager;
private readonly logger = new Logger();

View File

@@ -50,7 +50,9 @@ export class CreateNewJSFileCommand {
public static readonly id = 'javascript-walkthrough.commands.createJsFile';
public readonly id = CreateNewJSFileCommand.id;
constructor(private walkthroughState: JsWalkthroughState) { }
constructor(
private readonly walkthroughState: JsWalkthroughState
) { }
public execute() {
createNewJSFile(this.walkthroughState);
@@ -61,7 +63,9 @@ export class DebugJsFileCommand {
public static readonly id = 'javascript-walkthrough.commands.debugJsFile';
public readonly id = DebugJsFileCommand.id;
constructor(private walkthroughState: JsWalkthroughState) { }
constructor(
private readonly walkthroughState: JsWalkthroughState
) { }
public execute() {
debugJsFile(this.walkthroughState);