mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
@@ -8,7 +8,7 @@ import * as vscode from 'vscode';
|
||||
export interface Command {
|
||||
readonly id: string;
|
||||
|
||||
execute(...args: any[]): void | any;
|
||||
execute(...args: unknown[]): void | unknown;
|
||||
}
|
||||
|
||||
export class CommandManager {
|
||||
|
||||
@@ -13,7 +13,7 @@ export class ConfigurePluginCommand implements Command {
|
||||
private readonly pluginManager: PluginManager,
|
||||
) { }
|
||||
|
||||
public execute(pluginId: string, configuration: any) {
|
||||
public execute(pluginId: string, configuration: unknown) {
|
||||
this.pluginManager.setConfiguration(pluginId, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { TypeScriptRequests } from '../typescriptService';
|
||||
import { ExecConfig, TypeScriptRequests } from '../typescriptService';
|
||||
import TypeScriptServiceClientHost from '../typeScriptServiceClientHost';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
import { Lazy } from '../utils/lazy';
|
||||
@@ -26,7 +26,7 @@ export class TSServerRequestCommand implements Command {
|
||||
private readonly lazyClientHost: Lazy<TypeScriptServiceClientHost>
|
||||
) { }
|
||||
|
||||
public async execute(command: keyof TypeScriptRequests, args?: any, config?: any, token?: vscode.CancellationToken): Promise<unknown> {
|
||||
public async execute(command: keyof TypeScriptRequests, args?: unknown, config?: ExecConfig, token?: vscode.CancellationToken): Promise<unknown> {
|
||||
if (!isCancellationToken(token)) {
|
||||
token = nulToken;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class TSServerRequestCommand implements Command {
|
||||
const hasFile = requestArgs.file instanceof vscode.Uri;
|
||||
const hasTraceId = typeof requestArgs.$traceId === 'string';
|
||||
if (hasFile || hasTraceId) {
|
||||
const newArgs = { ...args };
|
||||
const newArgs = { file: undefined as string | undefined, ...args };
|
||||
if (hasFile) {
|
||||
const client = this.lazyClientHost.value.serviceClient;
|
||||
newArgs.file = client.toOpenTsFilePath(requestArgs.file);
|
||||
|
||||
@@ -56,7 +56,7 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
public readonly document: vscode.TextDocument,
|
||||
public readonly tsEntry: Proto.CompletionEntry,
|
||||
private readonly completionContext: CompletionContext,
|
||||
public readonly metadata: any | undefined,
|
||||
public readonly metadata: unknown | undefined,
|
||||
client: ITypeScriptServiceClient,
|
||||
defaultCommitCharacters: readonly string[] | undefined,
|
||||
) {
|
||||
|
||||
@@ -285,7 +285,7 @@ export class DiagnosticsManager extends Disposable {
|
||||
private readonly _diagnostics: ResourceMap<FileDiagnostics>;
|
||||
private readonly _settings = new DiagnosticSettings();
|
||||
private readonly _currentDiagnostics: vscode.DiagnosticCollection;
|
||||
private readonly _pendingUpdates: ResourceMap<any>;
|
||||
private readonly _pendingUpdates: ResourceMap</* timeout */ any>;
|
||||
|
||||
private readonly _updateDelay = 50;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class DidOrganizeImportsCommand implements Command {
|
||||
private readonly telemetryReporter: TelemetryReporter,
|
||||
) { }
|
||||
|
||||
public async execute(): Promise<any> {
|
||||
public async execute(): Promise<void> {
|
||||
/* __GDPR__
|
||||
"organizeImports.execute" : {
|
||||
"owner": "mjbvz",
|
||||
|
||||
@@ -16,17 +16,17 @@ export class Logger {
|
||||
return this.output.value.logLevel;
|
||||
}
|
||||
|
||||
public info(message: string, ...args: any[]): void {
|
||||
public info(message: string, ...args: unknown[]): void {
|
||||
this.output.value.info(message, ...args);
|
||||
}
|
||||
|
||||
public trace(message: string, ...args: any[]): void {
|
||||
public trace(message: string, ...args: unknown[]): void {
|
||||
this.output.value.trace(message, ...args);
|
||||
}
|
||||
|
||||
public error(message: string, data?: any): void {
|
||||
public error(message: string, data?: unknown): void {
|
||||
// See https://github.com/microsoft/TypeScript/issues/10496
|
||||
if (data && data.message === 'No content available.') {
|
||||
if (data && (data as { message?: string }).message === 'No content available.') {
|
||||
return;
|
||||
}
|
||||
this.output.value.error(message, ...(data ? [data] : []));
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class Tracer extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public traceRequestCompleted(serverId: string, command: string, request_seq: number, meta: RequestExecutionMetadata): any {
|
||||
public traceRequestCompleted(serverId: string, command: string, request_seq: number, meta: RequestExecutionMetadata): void {
|
||||
if (this.logger.logLevel === vscode.LogLevel.Trace) {
|
||||
this.trace(serverId, `Async response received: ${command} (${request_seq}). Request took ${Date.now() - meta.queuingStartTime} ms.`);
|
||||
}
|
||||
|
||||
@@ -349,15 +349,15 @@ class GetErrRequest {
|
||||
}
|
||||
}
|
||||
|
||||
private areProjectDiagnosticsEnabled() {
|
||||
private areProjectDiagnosticsEnabled(): boolean {
|
||||
return this.client.configuration.enableProjectDiagnostics && this.client.capabilities.has(ClientCapability.Semantic);
|
||||
}
|
||||
|
||||
private areRegionDiagnosticsEnabled() {
|
||||
private areRegionDiagnosticsEnabled(): boolean {
|
||||
return this.client.configuration.enableRegionDiagnostics && this.client.apiVersion.gte(API.v560);
|
||||
}
|
||||
|
||||
public cancel(): any {
|
||||
public cancel(): void {
|
||||
if (!this._done) {
|
||||
this._token.cancel();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace TypeScriptServerPlugin {
|
||||
}
|
||||
|
||||
export class PluginManager extends Disposable {
|
||||
private readonly _pluginConfigurations = new Map<string, {}>();
|
||||
private readonly _pluginConfigurations = new Map<string, unknown>();
|
||||
|
||||
private _plugins?: Map<string, ReadonlyArray<TypeScriptServerPlugin>>;
|
||||
|
||||
@@ -54,15 +54,15 @@ export class PluginManager extends Disposable {
|
||||
private readonly _onDidUpdatePlugins = this._register(new vscode.EventEmitter<this>());
|
||||
public readonly onDidChangePlugins = this._onDidUpdatePlugins.event;
|
||||
|
||||
private readonly _onDidUpdateConfig = this._register(new vscode.EventEmitter<{ pluginId: string; config: {} }>());
|
||||
private readonly _onDidUpdateConfig = this._register(new vscode.EventEmitter<{ pluginId: string; config: unknown }>());
|
||||
public readonly onDidUpdateConfig = this._onDidUpdateConfig.event;
|
||||
|
||||
public setConfiguration(pluginId: string, config: {}) {
|
||||
public setConfiguration(pluginId: string, config: unknown) {
|
||||
this._pluginConfigurations.set(pluginId, config);
|
||||
this._onDidUpdateConfig.fire({ pluginId, config });
|
||||
}
|
||||
|
||||
public configurations(): IterableIterator<[string, {}]> {
|
||||
public configurations(): IterableIterator<[string, unknown]> {
|
||||
return this._pluginConfigurations.entries();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ export type TsServerLog =
|
||||
export interface ITypeScriptServer {
|
||||
readonly onEvent: vscode.Event<Proto.Event>;
|
||||
readonly onExit: vscode.Event<TypeScriptServerExitEvent>;
|
||||
readonly onError: vscode.Event<any>;
|
||||
readonly onError: vscode.Event<unknown>;
|
||||
|
||||
readonly tsServerLog: TsServerLog | undefined;
|
||||
|
||||
@@ -125,7 +125,7 @@ export class SingleTsServer extends Disposable implements ITypeScriptServer {
|
||||
private readonly _onExit = this._register(new vscode.EventEmitter<TypeScriptServerExitEvent>());
|
||||
public readonly onExit = this._onExit.event;
|
||||
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<any>());
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<unknown>());
|
||||
public readonly onError = this._onError.event;
|
||||
|
||||
public get tsServerLog() { return this._tsServerLog; }
|
||||
@@ -528,7 +528,7 @@ export class GetErrRoutingTsServer extends Disposable implements ITypeScriptServ
|
||||
private readonly _onExit = this._register(new vscode.EventEmitter<TypeScriptServerExitEvent>());
|
||||
public readonly onExit = this._onExit.event;
|
||||
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<any>());
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<unknown>());
|
||||
public readonly onError = this._onError.event;
|
||||
|
||||
public get tsServerLog() { return this.mainServer.tsServerLog; }
|
||||
@@ -666,10 +666,10 @@ export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServ
|
||||
private readonly _onEvent = this._register(new vscode.EventEmitter<Proto.Event>());
|
||||
public readonly onEvent = this._onEvent.event;
|
||||
|
||||
private readonly _onExit = this._register(new vscode.EventEmitter<any>());
|
||||
private readonly _onExit = this._register(new vscode.EventEmitter<TypeScriptServerExitEvent>());
|
||||
public readonly onExit = this._onExit.event;
|
||||
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<any>());
|
||||
private readonly _onError = this._register(new vscode.EventEmitter<unknown>());
|
||||
public readonly onError = this._onError.event;
|
||||
|
||||
public get tsServerLog() { return this.semanticServer.tsServerLog; }
|
||||
|
||||
@@ -183,7 +183,7 @@ export class DiskTypeScriptVersionProvider implements ITypeScriptVersionProvider
|
||||
}
|
||||
|
||||
const contents = fs.readFileSync(fileName).toString();
|
||||
let desc: any = null;
|
||||
let desc: any;
|
||||
try {
|
||||
desc = JSON.parse(contents);
|
||||
} catch (err) {
|
||||
|
||||
@@ -444,12 +444,17 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
typeScriptVersionSource: version.source,
|
||||
});
|
||||
|
||||
handle.onError((err: Error) => {
|
||||
handle.onError((err: unknown) => {
|
||||
if (this.token !== mytoken) {
|
||||
// this is coming from an old process
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(err instanceof Error)) {
|
||||
this.logger.error('TSServer got unknown error type:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
vscode.window.showErrorMessage(vscode.l10n.t("TypeScript language server exited with error. Error message is: {0}", err.message || err.name));
|
||||
}
|
||||
@@ -851,7 +856,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return vscode.workspace.getWorkspaceFolder(resource)?.uri;
|
||||
}
|
||||
|
||||
public execute(command: keyof TypeScriptRequests, args: any, token: vscode.CancellationToken, config?: ExecConfig): Promise<ServerResponse.Response<Proto.Response>> {
|
||||
public execute(command: keyof TypeScriptRequests, args: unknown, token: vscode.CancellationToken, config?: ExecConfig): Promise<ServerResponse.Response<Proto.Response>> {
|
||||
let executions: Array<Promise<ServerResponse.Response<Proto.Response>> | undefined> | undefined;
|
||||
|
||||
if (config?.cancelOnResourceChange) {
|
||||
@@ -907,7 +912,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
return executions[0]!;
|
||||
}
|
||||
|
||||
public executeWithoutWaitingForResponse(command: keyof TypeScriptRequests, args: any): void {
|
||||
public executeWithoutWaitingForResponse(command: keyof TypeScriptRequests, args: unknown): void {
|
||||
this.executeImpl(command, args, {
|
||||
isAsync: false,
|
||||
token: undefined,
|
||||
@@ -923,7 +928,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
})[0]!;
|
||||
}
|
||||
|
||||
private executeImpl(command: keyof TypeScriptRequests, args: any, executeInfo: { isAsync: boolean; token?: vscode.CancellationToken; expectsResult: boolean; lowPriority?: boolean; requireSemantic?: boolean }): Array<Promise<ServerResponse.Response<Proto.Response>> | undefined> {
|
||||
private executeImpl(command: keyof TypeScriptRequests, args: unknown, executeInfo: { isAsync: boolean; token?: vscode.CancellationToken; expectsResult: boolean; lowPriority?: boolean; requireSemantic?: boolean }): Array<Promise<ServerResponse.Response<Proto.Response>> | undefined> {
|
||||
const serverState = this.serverState;
|
||||
if (serverState.type === ServerState.Type.Running) {
|
||||
this.bufferSyncSupport.beforeCommand(command);
|
||||
@@ -1230,7 +1235,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
this.telemetryReporter.logTelemetry(telemetryData.telemetryEventName, properties);
|
||||
}
|
||||
|
||||
private configurePlugin(pluginName: string, configuration: {}): any {
|
||||
private configurePlugin(pluginName: string, configuration: unknown): void {
|
||||
this.executeWithoutWaitingForResponse('configurePlugin', { pluginName, configuration });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class Delayer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
|
||||
export function setImmediate(callback: (...args: unknown[]) => void, ...args: unknown[]): Disposable {
|
||||
if (global.setImmediate) {
|
||||
const handle = global.setImmediate(callback, ...args);
|
||||
return { dispose: () => global.clearImmediate(handle) };
|
||||
|
||||
@@ -74,16 +74,16 @@ function createServerHost(
|
||||
return {
|
||||
watchFile: watchManager.watchFile.bind(watchManager),
|
||||
watchDirectory: watchManager.watchDirectory.bind(watchManager),
|
||||
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
|
||||
setTimeout(callback: (...args: unknown[]) => void, ms: number, ...args: unknown[]): unknown {
|
||||
return setTimeout(callback, ms, ...args);
|
||||
},
|
||||
clearTimeout(timeoutId: any): void {
|
||||
clearTimeout(timeoutId);
|
||||
},
|
||||
setImmediate(callback: (...args: any[]) => void, ...args: any[]): any {
|
||||
setImmediate(callback: (...args: unknown[]) => void, ...args: unknown[]): unknown {
|
||||
return this.setTimeout(callback, 0, ...args);
|
||||
},
|
||||
clearImmediate(timeoutId: any): void {
|
||||
clearImmediate(timeoutId: unknown): void {
|
||||
this.clearTimeout(timeoutId);
|
||||
},
|
||||
importPlugin: async (root, moduleName) => {
|
||||
|
||||
Reference in New Issue
Block a user