From 0ac8174fbcf3ac0bfb41b32e498d336f604dd9af Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 11 Jun 2025 11:51:06 +0200 Subject: [PATCH] debt - reduce some explicit `any` use (#251182) --- src/vs/base/browser/markdownRenderer.ts | 2 +- .../browser/ui/breadcrumbs/breadcrumbsWidget.ts | 2 +- src/vs/base/browser/ui/grid/grid.ts | 2 +- src/vs/base/browser/ui/grid/gridview.ts | 2 +- src/vs/base/common/async.ts | 2 +- src/vs/base/common/dataTransfer.ts | 2 +- src/vs/base/common/jsonEdit.ts | 2 +- .../observableInternal/experimental/utils.ts | 2 +- src/vs/base/common/product.ts | 2 +- src/vs/base/common/worker/webWorkerBootstrap.ts | 2 +- src/vs/editor/common/editorCommon.ts | 2 +- .../browser/model/inlineCompletionsSource.ts | 6 +++--- .../semanticTokens/common/getSemanticTokens.ts | 2 +- .../instantiation/common/instantiationService.ts | 2 +- src/vs/platform/list/browser/listService.ts | 7 ------- .../remote/browser/browserSocketFactory.ts | 14 +++++++------- .../remote/common/remoteAuthorityResolver.ts | 4 ++-- src/vs/platform/terminal/node/ptyService.ts | 2 +- src/vs/platform/userDataSync/common/content.ts | 2 +- src/vs/server/node/remoteExtensionsScanner.ts | 14 +++++++------- .../api/browser/mainThreadConfiguration.ts | 6 +++--- src/vs/workbench/api/common/extHost.protocol.ts | 7 ++++--- .../workbench/api/common/extHostConfiguration.ts | 4 ++-- .../api/common/extHostLanguageModelTools.ts | 2 +- .../workbench/api/common/extHostLanguageModels.ts | 2 +- .../workbench/api/common/extHostNotebookKernels.ts | 4 ++-- .../api/common/extHostNotebookRenderers.ts | 2 +- src/vs/workbench/api/common/extHostSCM.ts | 2 +- .../workbench/api/common/extHostTypeConverters.ts | 2 +- src/vs/workbench/api/common/extHostTypes.ts | 4 ++-- .../api/common/extHostWebviewMessaging.ts | 6 +++--- .../browser/parts/editor/breadcrumbsControl.ts | 2 +- .../browser/parts/editor/breadcrumbsPicker.ts | 2 +- .../contrib/debug/browser/callStackView.ts | 2 +- .../configuration/browser/configurationService.ts | 12 ++++++------ .../configuration/common/configurationEditing.ts | 2 +- .../services/configuration/common/jsonEditing.ts | 2 +- .../browser/baseConfigurationResolverService.ts | 4 ++-- .../common/configurationResolver.ts | 4 ++-- .../services/themes/common/themeConfiguration.ts | 2 +- 40 files changed, 71 insertions(+), 77 deletions(-) diff --git a/src/vs/base/browser/markdownRenderer.ts b/src/vs/base/browser/markdownRenderer.ts index 2cb748afcdf..54e6fd71b87 100644 --- a/src/vs/base/browser/markdownRenderer.ts +++ b/src/vs/base/browser/markdownRenderer.ts @@ -323,7 +323,7 @@ function activateLink(markdown: IMarkdownString, options: MarkdownRenderOptions, } function uriMassage(markdown: IMarkdownString, part: string): string { - let data: any; + let data: unknown; try { data = parse(decodeURIComponent(part)); } catch (e) { diff --git a/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts b/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts index a4cb3361f9d..01e522130a9 100644 --- a/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts +++ b/src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts @@ -32,7 +32,7 @@ export interface IBreadcrumbsItemEvent { type: 'select' | 'focus'; item: BreadcrumbsItem; node: HTMLElement; - payload: any; + payload: unknown; } export class BreadcrumbsWidget { diff --git a/src/vs/base/browser/ui/grid/grid.ts b/src/vs/base/browser/ui/grid/grid.ts index cd7aabf6cfb..882c2e980fb 100644 --- a/src/vs/base/browser/ui/grid/grid.ts +++ b/src/vs/base/browser/ui/grid/grid.ts @@ -749,7 +749,7 @@ export interface IViewDeserializer { export interface ISerializedLeafNode { type: 'leaf'; - data: any; + data: unknown; size: number; visible?: boolean; maximized?: boolean; diff --git a/src/vs/base/browser/ui/grid/gridview.ts b/src/vs/base/browser/ui/grid/gridview.ts index 09452c14992..bf3d737867f 100644 --- a/src/vs/base/browser/ui/grid/gridview.ts +++ b/src/vs/base/browser/ui/grid/gridview.ts @@ -145,7 +145,7 @@ export interface IViewDeserializer { export interface ISerializedLeafNode { type: 'leaf'; - data: any; + data: unknown; size: number; visible?: boolean; maximized?: boolean; diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index ca964301327..fb72d242be6 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -1743,7 +1743,7 @@ export class DeferredPromise { private completeCallback!: ValueCallback; private errorCallback!: (err: unknown) => void; - private outcome?: { outcome: DeferredOutcome.Rejected; value: any } | { outcome: DeferredOutcome.Resolved; value: T }; + private outcome?: { outcome: DeferredOutcome.Rejected; value: unknown } | { outcome: DeferredOutcome.Resolved; value: T }; public get isRejected() { return this.outcome?.outcome === DeferredOutcome.Rejected; diff --git a/src/vs/base/common/dataTransfer.ts b/src/vs/base/common/dataTransfer.ts index 3ce5770c57f..9f504a20c5a 100644 --- a/src/vs/base/common/dataTransfer.ts +++ b/src/vs/base/common/dataTransfer.ts @@ -19,7 +19,7 @@ export interface IDataTransferItem { id?: string; asString(): Thenable; asFile(): IDataTransferFile | undefined; - value: any; + value: unknown; } export function createStringDataTransferItem(stringOrPromise: string | Promise, id?: string): IDataTransferItem { diff --git a/src/vs/base/common/jsonEdit.ts b/src/vs/base/common/jsonEdit.ts index c699dbcb569..b3ae24ae69a 100644 --- a/src/vs/base/common/jsonEdit.ts +++ b/src/vs/base/common/jsonEdit.ts @@ -11,7 +11,7 @@ export function removeProperty(text: string, path: JSONPath, formattingOptions: return setProperty(text, path, undefined, formattingOptions); } -export function setProperty(text: string, originalPath: JSONPath, value: any, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] { +export function setProperty(text: string, originalPath: JSONPath, value: unknown, formattingOptions: FormattingOptions, getInsertionIndex?: (properties: string[]) => number): Edit[] { const path = originalPath.slice(); const errors: ParseError[] = []; const root = parseTree(text, errors); diff --git a/src/vs/base/common/observableInternal/experimental/utils.ts b/src/vs/base/common/observableInternal/experimental/utils.ts index 3a64aae46f2..a9038ac0946 100644 --- a/src/vs/base/common/observableInternal/experimental/utils.ts +++ b/src/vs/base/common/observableInternal/experimental/utils.ts @@ -22,7 +22,7 @@ export function latestChangedValue[]>(owner: DebugOwn } let hasLastChangedValue = false; - let lastChangedValue: any = undefined; + let lastChangedValue: unknown = undefined; const result = observableFromEvent(owner, cb => { const store = new DisposableStore(); diff --git a/src/vs/base/common/product.ts b/src/vs/base/common/product.ts index c3df2a13a97..653a85bb523 100644 --- a/src/vs/base/common/product.ts +++ b/src/vs/base/common/product.ts @@ -11,7 +11,7 @@ export interface IBuiltInExtension { readonly name: string; readonly version: string; readonly repo: string; - readonly metadata: any; + readonly metadata: unknown; } export interface IProductWalkthrough { diff --git a/src/vs/base/common/worker/webWorkerBootstrap.ts b/src/vs/base/common/worker/webWorkerBootstrap.ts index dce9e79b757..946c3e98be9 100644 --- a/src/vs/base/common/worker/webWorkerBootstrap.ts +++ b/src/vs/base/common/worker/webWorkerBootstrap.ts @@ -6,7 +6,7 @@ import { IWebWorkerServerRequestHandler, IWebWorkerServerRequestHandlerFactory, WebWorkerServer } from './webWorker.js'; type MessageEvent = { - data: any; + data: unknown; }; declare const globalThis: { diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 3d0210dc4c4..ba900f3a584 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -153,7 +153,7 @@ export interface IContentSizeChangedEvent { export interface ITriggerEditorOperationEvent { source: string | null | undefined; handlerId: string; - payload: any; + payload: unknown; } export interface INewScrollPosition { diff --git a/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts b/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts index 499d0e0122d..029c0ec23a2 100644 --- a/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts +++ b/src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.ts @@ -57,7 +57,7 @@ export class InlineCompletionsSource extends Disposable { this._loggingEnabled = observableConfigValue('editor.inlineSuggest.logFetch', false, this._configurationService).recomputeInitiallyAndOnChange(this._store); this._structuredFetchLogger = this._register(this._instantiationService.createInstance(StructuredLogger.cast< { kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry - | { kind: 'end'; error: any; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry + | { kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry >(), 'editor.inlineSuggest.logFetch.commandId' )); @@ -105,7 +105,7 @@ export class InlineCompletionsSource extends Disposable { private _log(entry: { sourceId: string; kind: 'start'; requestId: number; context: unknown } & IRecordableEditorLogEntry - | { sourceId: string; kind: 'end'; error: any; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry + | { sourceId: string; kind: 'end'; error: unknown; durationMs: number; result: unknown; requestId: number } & IRecordableLogEntry ) { if (this._loggingEnabled.get()) { this._logService.info(formatRecordableLogEntry(entry)); @@ -159,7 +159,7 @@ export class InlineCompletionsSource extends Disposable { const startTime = new Date(); let providerResult: InlineCompletionProviderResult | undefined = undefined; - let error: any = undefined; + let error: unknown = undefined; try { providerResult = await provideInlineCompletions( providers, diff --git a/src/vs/editor/contrib/semanticTokens/common/getSemanticTokens.ts b/src/vs/editor/contrib/semanticTokens/common/getSemanticTokens.ts index cd7cbd3e7c1..137abcc4826 100644 --- a/src/vs/editor/contrib/semanticTokens/common/getSemanticTokens.ts +++ b/src/vs/editor/contrib/semanticTokens/common/getSemanticTokens.ts @@ -48,7 +48,7 @@ export async function getDocumentSemanticTokens(registry: LanguageFeatureRegistr // Get tokens from all providers at the same time. const results = await Promise.all(providers.map(async (provider) => { let result: SemanticTokens | SemanticTokensEdits | null | undefined; - let error: any = null; + let error: unknown = null; try { result = await provider.provideDocumentSemanticTokens(model, (provider === lastProvider ? lastResultId : null), token); } catch (err) { diff --git a/src/vs/platform/instantiation/common/instantiationService.ts b/src/vs/platform/instantiation/common/instantiationService.ts index 86099cc8b66..77950178326 100644 --- a/src/vs/platform/instantiation/common/instantiationService.ts +++ b/src/vs/platform/instantiation/common/instantiationService.ts @@ -119,7 +119,7 @@ export class InstantiationService implements IInstantiationService { this._throwIfDisposed(); let _trace: Trace; - let result: any; + let result: unknown; if (ctorOrDescriptor instanceof SyncDescriptor) { _trace = Trace.traceCreation(this._enableTracing, ctorOrDescriptor.ctor); result = this._createInstance(ctorOrDescriptor.ctor, ctorOrDescriptor.staticArguments.concat(rest), _trace); diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index 94c2acead57..27b1a2be4da 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -646,13 +646,6 @@ export class WorkbenchTable extends Table { } } -export interface IOpenResourceOptions { - editorOptions: IEditorOptions; - sideBySide: boolean; - element: any; - payload: any; -} - export interface IOpenEvent { editorOptions: IEditorOptions; sideBySide: boolean; diff --git a/src/vs/platform/remote/browser/browserSocketFactory.ts b/src/vs/platform/remote/browser/browserSocketFactory.ts index 7aea766301a..0f01fc06138 100644 --- a/src/vs/platform/remote/browser/browserSocketFactory.ts +++ b/src/vs/platform/remote/browser/browserSocketFactory.ts @@ -33,16 +33,16 @@ export interface IWebSocketCloseEvent { /** * Underlying event. */ - readonly event: any | undefined; + readonly event: unknown | undefined; } export interface IWebSocket { readonly onData: Event; readonly onOpen: Event; readonly onClose: Event; - readonly onError: Event; + readonly onError: Event; - traceSocketEvent?(type: SocketDiagnosticsEventType, data?: VSBuffer | Uint8Array | ArrayBuffer | ArrayBufferView | any): void; + traceSocketEvent?(type: SocketDiagnosticsEventType, data?: VSBuffer | Uint8Array | ArrayBuffer | ArrayBufferView | unknown): void; send(data: ArrayBuffer | ArrayBufferView): void; close(): void; } @@ -58,7 +58,7 @@ class BrowserWebSocket extends Disposable implements IWebSocket { private readonly _onClose = this._register(new Emitter()); public readonly onClose = this._onClose.event; - private readonly _onError = this._register(new Emitter()); + private readonly _onError = this._register(new Emitter()); public readonly onError = this._onError.event; private readonly _debugLabel: string; @@ -127,7 +127,7 @@ class BrowserWebSocket extends Disposable implements IWebSocket { // delay the error event processing in the hope of receiving a close event // with more information - let pendingErrorEvent: any | null = null; + let pendingErrorEvent: unknown | null = null; const sendPendingErrorNow = () => { const err = pendingErrorEvent; @@ -137,13 +137,13 @@ class BrowserWebSocket extends Disposable implements IWebSocket { const errorRunner = this._register(new RunOnceScheduler(sendPendingErrorNow, 0)); - const sendErrorSoon = (err: any) => { + const sendErrorSoon = (err: unknown) => { errorRunner.cancel(); pendingErrorEvent = err; errorRunner.schedule(); }; - const sendErrorNow = (err: any) => { + const sendErrorNow = (err: unknown) => { errorRunner.cancel(); pendingErrorEvent = err; sendPendingErrorNow(); diff --git a/src/vs/platform/remote/common/remoteAuthorityResolver.ts b/src/vs/platform/remote/common/remoteAuthorityResolver.ts index 938bbd80c48..56fb35c3f67 100644 --- a/src/vs/platform/remote/common/remoteAuthorityResolver.ts +++ b/src/vs/platform/remote/common/remoteAuthorityResolver.ts @@ -120,11 +120,11 @@ export class RemoteAuthorityResolverError extends ErrorNoTelemetry { public readonly _message: string | undefined; public readonly _code: RemoteAuthorityResolverErrorCode; - public readonly _detail: any; + public readonly _detail: unknown; public isHandled: boolean; - constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) { + constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: unknown) { super(message); this._message = message; diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 01e98822f2f..a43f323716b 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -49,7 +49,7 @@ export function traceRpc(_target: any, key: string, descriptor: any) { if (this.traceRpcArgs.simulatedLatency) { await timeout(this.traceRpcArgs.simulatedLatency); } - let result: any; + let result: unknown; try { result = await fn.apply(this, args); } catch (e) { diff --git a/src/vs/platform/userDataSync/common/content.ts b/src/vs/platform/userDataSync/common/content.ts index 77a6f04dffa..3f3af755f14 100644 --- a/src/vs/platform/userDataSync/common/content.ts +++ b/src/vs/platform/userDataSync/common/content.ts @@ -8,7 +8,7 @@ import { setProperty } from '../../../base/common/jsonEdit.js'; import { FormattingOptions } from '../../../base/common/jsonFormatter.js'; -export function edit(content: string, originalPath: JSONPath, value: any, formattingOptions: FormattingOptions): string { +export function edit(content: string, originalPath: JSONPath, value: unknown, formattingOptions: FormattingOptions): string { const edit = setProperty(content, originalPath, value, formattingOptions)[0]; if (edit) { content = content.substring(0, edit.offset) + edit.content + content.substring(edit.offset + edit.length); diff --git a/src/vs/server/node/remoteExtensionsScanner.ts b/src/vs/server/node/remoteExtensionsScanner.ts index 1bd6cf68c1d..bbc82fd06bc 100644 --- a/src/vs/server/node/remoteExtensionsScanner.ts +++ b/src/vs/server/node/remoteExtensionsScanner.ts @@ -11,7 +11,7 @@ import * as performance from '../../base/common/performance.js'; import { Event } from '../../base/common/event.js'; import { IURITransformer, transformOutgoingURIs } from '../../base/common/uriIpc.js'; import { IServerChannel } from '../../base/parts/ipc/common/ipc.js'; -import { ContextKeyDefinedExpr, ContextKeyEqualsExpr, ContextKeyExpr, ContextKeyExpression, ContextKeyGreaterEqualsExpr, ContextKeyGreaterExpr, ContextKeyInExpr, ContextKeyNotEqualsExpr, ContextKeyNotExpr, ContextKeyNotInExpr, ContextKeyRegexExpr, ContextKeySmallerEqualsExpr, ContextKeySmallerExpr, IContextKeyExprMapper } from '../../platform/contextkey/common/contextkey.js'; +import { ContextKeyDefinedExpr, ContextKeyEqualsExpr, ContextKeyExpr, ContextKeyExpression, ContextKeyGreaterEqualsExpr, ContextKeyGreaterExpr, ContextKeyInExpr, ContextKeyNotEqualsExpr, ContextKeyNotExpr, ContextKeyNotInExpr, ContextKeyRegexExpr, ContextKeySmallerEqualsExpr, ContextKeySmallerExpr, ContextKeyValue, IContextKeyExprMapper } from '../../platform/contextkey/common/contextkey.js'; import { IExtensionGalleryService, IExtensionManagementService, InstallExtensionSummary, InstallOptions } from '../../platform/extensionManagement/common/extensionManagement.js'; import { ExtensionManagementCLI } from '../../platform/extensionManagement/common/extensionManagementCLI.js'; import { IExtensionsScannerService, toExtensionDescription } from '../../platform/extensionManagement/common/extensionsScannerService.js'; @@ -238,30 +238,30 @@ export class RemoteExtensionsScannerService implements IRemoteExtensionsScannerS mapNot(key: string): ContextKeyExpression { return ContextKeyNotExpr.create(key); } - mapEquals(key: string, value: any): ContextKeyExpression { + mapEquals(key: string, value: ContextKeyValue): ContextKeyExpression { if (key === 'resourceScheme' && typeof value === 'string') { return ContextKeyEqualsExpr.create(key, _mapResourceSchemeValue(value, false)); } else { return ContextKeyEqualsExpr.create(key, value); } } - mapNotEquals(key: string, value: any): ContextKeyExpression { + mapNotEquals(key: string, value: ContextKeyValue): ContextKeyExpression { if (key === 'resourceScheme' && typeof value === 'string') { return ContextKeyNotEqualsExpr.create(key, _mapResourceSchemeValue(value, false)); } else { return ContextKeyNotEqualsExpr.create(key, value); } } - mapGreater(key: string, value: any): ContextKeyExpression { + mapGreater(key: string, value: ContextKeyValue): ContextKeyExpression { return ContextKeyGreaterExpr.create(key, value); } - mapGreaterEquals(key: string, value: any): ContextKeyExpression { + mapGreaterEquals(key: string, value: ContextKeyValue): ContextKeyExpression { return ContextKeyGreaterEqualsExpr.create(key, value); } - mapSmaller(key: string, value: any): ContextKeyExpression { + mapSmaller(key: string, value: ContextKeyValue): ContextKeyExpression { return ContextKeySmallerExpr.create(key, value); } - mapSmallerEquals(key: string, value: any): ContextKeyExpression { + mapSmallerEquals(key: string, value: ContextKeyValue): ContextKeyExpression { return ContextKeySmallerEqualsExpr.create(key, value); } mapRegex(key: string, regexp: RegExp | null): ContextKeyRegexExpr { diff --git a/src/vs/workbench/api/browser/mainThreadConfiguration.ts b/src/vs/workbench/api/browser/mainThreadConfiguration.ts index 86891475af3..07c29c26ee9 100644 --- a/src/vs/workbench/api/browser/mainThreadConfiguration.ts +++ b/src/vs/workbench/api/browser/mainThreadConfiguration.ts @@ -45,7 +45,7 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape { this._configurationListener.dispose(); } - $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise { + $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: unknown, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise { overrides = { resource: overrides?.resource ? URI.revive(overrides.resource) : undefined, overrideIdentifier: overrides?.overrideIdentifier }; return this.writeConfiguration(target, key, value, overrides, scopeToLanguage); } @@ -55,7 +55,7 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape { return this.writeConfiguration(target, key, undefined, overrides, scopeToLanguage); } - private writeConfiguration(target: ConfigurationTarget | null, key: string, value: any, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise { + private writeConfiguration(target: ConfigurationTarget | null, key: string, value: unknown, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise { target = target !== null && target !== undefined ? target : this.deriveConfigurationTarget(key, overrides); const configurationValue = this.configurationService.inspect(key, overrides); switch (target) { @@ -72,7 +72,7 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape { } } - private _updateValue(key: string, value: any, configurationTarget: ConfigurationTarget, overriddenValue: any | undefined, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise { + private _updateValue(key: string, value: unknown, configurationTarget: ConfigurationTarget, overriddenValue: any | undefined, overrides: IConfigurationOverrides, scopeToLanguage: boolean | undefined): Promise { overrides = scopeToLanguage === true ? overrides : scopeToLanguage === false ? { resource: overrides.resource } : overrides.overrideIdentifier && overriddenValue !== undefined ? overrides diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index a4e53cbd021..8a5d067160d 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -68,6 +68,7 @@ import * as notebookCommon from '../../contrib/notebook/common/notebookCommon.js import { CellExecutionUpdateType } from '../../contrib/notebook/common/notebookExecutionService.js'; import { ICellExecutionComplete, ICellExecutionStateUpdate } from '../../contrib/notebook/common/notebookExecutionStateService.js'; import { ICellRange } from '../../contrib/notebook/common/notebookRange.js'; +import { ISCMHistoryOptions } from '../../contrib/scm/common/history.js'; import { InputValidationType } from '../../contrib/scm/common/scm.js'; import { IWorkspaceSymbol, NotebookPriorityInfo } from '../../contrib/search/common/search.js'; import { IRawClosedNotebookFileMatch } from '../../contrib/search/common/searchNotebookHelpers.js'; @@ -203,7 +204,7 @@ export interface MainThreadSecretStateShape extends IDisposable { } export interface MainThreadConfigurationShape extends IDisposable { - $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: any, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise; + $updateConfigurationOption(target: ConfigurationTarget | null, key: string, value: unknown, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise; $removeConfigurationOption(target: ConfigurationTarget | null, key: string, overrides: IConfigurationOverrides | undefined, scopeToLanguage: boolean | undefined): Promise; } @@ -1409,7 +1410,7 @@ export interface ExtHostLanguageModelToolsShape { $invokeTool(dto: IToolInvocation, token: CancellationToken): Promise | SerializableObjectWithBuffers>>; $countTokensForInvocation(callId: string, input: string, token: CancellationToken): Promise; - $prepareToolInvocation(toolId: string, parameters: any, token: CancellationToken): Promise; + $prepareToolInvocation(toolId: string, parameters: unknown, token: CancellationToken): Promise; } export interface MainThreadUrlsShape extends IDisposable { @@ -2570,7 +2571,7 @@ export interface ExtHostSCMShape { $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string | IMarkdownString, number] | undefined>; $setSelectedSourceControl(selectedSourceControlHandle: number | undefined): Promise; $provideHistoryItemRefs(sourceControlHandle: number, historyItemRefs: string[] | undefined, token: CancellationToken): Promise; - $provideHistoryItems(sourceControlHandle: number, options: any, token: CancellationToken): Promise; + $provideHistoryItems(sourceControlHandle: number, options: ISCMHistoryOptions, token: CancellationToken): Promise; $provideHistoryItemChanges(sourceControlHandle: number, historyItemId: string, historyItemParentId: string | undefined, token: CancellationToken): Promise; $resolveHistoryItemChatContext(sourceControlHandle: number, historyItemId: string, token: CancellationToken): Promise; $resolveHistoryItemRefsCommonAncestor(sourceControlHandle: number, historyItemRefs: string[], token: CancellationToken): Promise; diff --git a/src/vs/workbench/api/common/extHostConfiguration.ts b/src/vs/workbench/api/common/extHostConfiguration.ts index f0d9124a0da..425d303ff88 100644 --- a/src/vs/workbench/api/common/extHostConfiguration.ts +++ b/src/vs/workbench/api/common/extHostConfiguration.ts @@ -247,7 +247,7 @@ export class ExtHostConfigProvider { } return result; }, - update: (key: string, value: any, extHostConfigurationTarget: ExtHostConfigurationTarget | boolean, scopeToLanguage?: boolean) => { + update: (key: string, value: unknown, extHostConfigurationTarget: ExtHostConfigurationTarget | boolean, scopeToLanguage?: boolean) => { key = section ? `${section}.${key}` : key; const target = parseConfigurationTarget(extHostConfigurationTarget); if (value !== undefined) { @@ -299,7 +299,7 @@ export class ExtHostConfigProvider { set: (_target: any, property: PropertyKey, _value: any) => { throw new Error(`TypeError: Cannot assign to read only property '${String(property)}' of object`); }, deleteProperty: (_target: any, property: PropertyKey) => { throw new Error(`TypeError: Cannot delete read only property '${String(property)}' of object`); }, defineProperty: (_target: any, property: PropertyKey) => { throw new Error(`TypeError: Cannot define property '${String(property)}' for a readonly object`); }, - setPrototypeOf: (_target: any) => { throw new Error(`TypeError: Cannot set prototype for a readonly object`); }, + setPrototypeOf: (_target: unknown) => { throw new Error(`TypeError: Cannot set prototype for a readonly object`); }, isExtensible: () => false, preventExtensions: () => true }) : target; diff --git a/src/vs/workbench/api/common/extHostLanguageModelTools.ts b/src/vs/workbench/api/common/extHostLanguageModelTools.ts index bc1b1a263a2..f90a6a5d6e2 100644 --- a/src/vs/workbench/api/common/extHostLanguageModelTools.ts +++ b/src/vs/workbench/api/common/extHostLanguageModelTools.ts @@ -220,7 +220,7 @@ export class ExtHostLanguageModelTools implements ExtHostLanguageModelToolsShape return model; } - async $prepareToolInvocation(toolId: string, input: any, token: CancellationToken): Promise { + async $prepareToolInvocation(toolId: string, input: unknown, token: CancellationToken): Promise { const item = this._registeredTools.get(toolId); if (!item) { throw new Error(`Unknown tool ${toolId}`); diff --git a/src/vs/workbench/api/common/extHostLanguageModels.ts b/src/vs/workbench/api/common/extHostLanguageModels.ts index 2ab508631e7..f2fcab92ffc 100644 --- a/src/vs/workbench/api/common/extHostLanguageModels.ts +++ b/src/vs/workbench/api/common/extHostLanguageModels.ts @@ -263,7 +263,7 @@ export class ExtHostLanguageModels implements ExtHostLanguageModelsShape { sendSoon({ index: fragment.index, part }); }); - let value: any; + let value: unknown; try { value = data.provider.provideLanguageModelResponse( diff --git a/src/vs/workbench/api/common/extHostNotebookKernels.ts b/src/vs/workbench/api/common/extHostNotebookKernels.ts index d96cbc78588..6e11a2c8d6b 100644 --- a/src/vs/workbench/api/common/extHostNotebookKernels.ts +++ b/src/vs/workbench/api/common/extHostNotebookKernels.ts @@ -31,7 +31,7 @@ interface IKernelData { extensionId: ExtensionIdentifier; controller: vscode.NotebookController; onDidChangeSelection: Emitter<{ selected: boolean; notebook: vscode.NotebookDocument }>; - onDidReceiveMessage: Emitter<{ editor: vscode.NotebookEditor; message: any }>; + onDidReceiveMessage: Emitter<{ editor: vscode.NotebookEditor; message: unknown }>; associatedNotebooks: ResourceMap; } @@ -135,7 +135,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape { let isDisposed = false; const onDidChangeSelection = new Emitter<{ selected: boolean; notebook: vscode.NotebookDocument }>(); - const onDidReceiveMessage = new Emitter<{ editor: vscode.NotebookEditor; message: any }>(); + const onDidReceiveMessage = new Emitter<{ editor: vscode.NotebookEditor; message: unknown }>(); const data: INotebookKernelDto2 = { id: createKernelId(extension.identifier, id), diff --git a/src/vs/workbench/api/common/extHostNotebookRenderers.ts b/src/vs/workbench/api/common/extHostNotebookRenderers.ts index 56c273a7b0d..27035ab4590 100644 --- a/src/vs/workbench/api/common/extHostNotebookRenderers.ts +++ b/src/vs/workbench/api/common/extHostNotebookRenderers.ts @@ -12,7 +12,7 @@ import * as vscode from 'vscode'; export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape { - private readonly _rendererMessageEmitters = new Map>(); + private readonly _rendererMessageEmitters = new Map>(); private readonly proxy: MainThreadNotebookRenderersShape; constructor(mainContext: IMainContext, private readonly _extHostNotebook: ExtHostNotebookController) { diff --git a/src/vs/workbench/api/common/extHostSCM.ts b/src/vs/workbench/api/common/extHostSCM.ts index eb77029e5f4..236a32470f5 100644 --- a/src/vs/workbench/api/common/extHostSCM.ts +++ b/src/vs/workbench/api/common/extHostSCM.ts @@ -1085,7 +1085,7 @@ export class ExtHostSCM implements ExtHostSCMShape { } } - async $provideHistoryItems(sourceControlHandle: number, options: any, token: CancellationToken): Promise { + async $provideHistoryItems(sourceControlHandle: number, options: vscode.SourceControlHistoryOptions, token: CancellationToken): Promise { try { const historyProvider = this._sourceControls.get(sourceControlHandle)?.historyProvider; const historyItems = await historyProvider?.provideHistoryItems(options, token); diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 02f78542290..35e2cc93dea 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -406,7 +406,7 @@ export namespace MarkdownString { if (!part) { return part; } - let data: any; + let data: unknown; try { data = parse(part); } catch (e) { diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 8984ceb7d0b..0f79fd6e814 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -584,9 +584,9 @@ export class RemoteAuthorityResolverError extends Error { public readonly _message: string | undefined; public readonly _code: RemoteAuthorityResolverErrorCode; - public readonly _detail: any; + public readonly _detail: unknown; - constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) { + constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: unknown) { super(message); this._message = message; diff --git a/src/vs/workbench/api/common/extHostWebviewMessaging.ts b/src/vs/workbench/api/common/extHostWebviewMessaging.ts index 49f0fa06c99..97a9de1b30c 100644 --- a/src/vs/workbench/api/common/extHostWebviewMessaging.ts +++ b/src/vs/workbench/api/common/extHostWebviewMessaging.ts @@ -20,7 +20,7 @@ class ArrayBufferSet { } export function serializeWebviewMessage( - message: any, + message: unknown, options: { serializeBuffersForPostMessage?: boolean } ): { message: string; buffers: VSBuffer[] } { if (options.serializeBuffersForPostMessage) { @@ -83,7 +83,7 @@ function getTypedArrayType(value: ArrayBufferView): extHostProtocol.WebviewMessa return undefined; } -export function deserializeWebviewMessage(jsonMessage: string, buffers: VSBuffer[]): { message: any; arrayBuffers: ArrayBuffer[] } { +export function deserializeWebviewMessage(jsonMessage: string, buffers: VSBuffer[]): { message: unknown; arrayBuffers: ArrayBuffer[] } { const arrayBuffers: ArrayBuffer[] = buffers.map(buffer => { const arrayBuffer = new ArrayBuffer(buffer.byteLength); const uint8Array = new Uint8Array(arrayBuffer); @@ -117,6 +117,6 @@ export function deserializeWebviewMessage(jsonMessage: string, buffers: VSBuffer return value; }; - const message = JSON.parse(jsonMessage, reviver); + const message = JSON.parse(jsonMessage, reviver) as unknown; return { message, arrayBuffers }; } diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts index 838d74fd56f..a72236d0c57 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts @@ -576,7 +576,7 @@ export class BreadcrumbsControl { } } - private _getEditorGroup(data: object): SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE | undefined { + private _getEditorGroup(data: unknown): SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE | undefined { if (data === BreadcrumbsControl.Payload_RevealAside) { return SIDE_GROUP; } else if (data === BreadcrumbsControl.Payload_Reveal) { diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts index e01631d1552..fd784e6f69b 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts @@ -82,7 +82,7 @@ export abstract class BreadcrumbsPicker { setTimeout(() => this._tree.dispose(), 0); // tree cannot be disposed while being opened... } - async show(input: any, maxHeight: number, width: number, arrowSize: number, arrowOffset: number): Promise { + async show(input: FileElement | OutlineElement2, maxHeight: number, width: number, arrowSize: number, arrowOffset: number): Promise { const theme = this._themeService.getColorTheme(); const color = theme.getColor(breadcrumbsPickerBackground); diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index a3083b15868..e853bcdeed5 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -74,7 +74,7 @@ function assignStackFrameContext(element: StackFrame, context: any) { return context; } -export function getContext(element: CallStackItem | null): any { +export function getContext(element: CallStackItem | null) { if (element instanceof StackFrame) { return assignStackFrameContext(element, {}); } else if (element instanceof Thread) { diff --git a/src/vs/workbench/services/configuration/browser/configurationService.ts b/src/vs/workbench/services/configuration/browser/configurationService.ts index c56106ddd6a..e3715ce5097 100644 --- a/src/vs/workbench/services/configuration/browser/configurationService.ts +++ b/src/vs/workbench/services/configuration/browser/configurationService.ts @@ -332,10 +332,10 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat } updateValue(key: string, value: any): Promise; - updateValue(key: string, value: any, overrides: IConfigurationOverrides | IConfigurationUpdateOverrides): Promise; - updateValue(key: string, value: any, target: ConfigurationTarget): Promise; - updateValue(key: string, value: any, overrides: IConfigurationOverrides | IConfigurationUpdateOverrides, target: ConfigurationTarget, options?: IConfigurationUpdateOptions): Promise; - async updateValue(key: string, value: any, arg3?: any, arg4?: any, options?: any): Promise { + updateValue(key: string, value: unknown, overrides: IConfigurationOverrides | IConfigurationUpdateOverrides): Promise; + updateValue(key: string, value: unknown, target: ConfigurationTarget): Promise; + updateValue(key: string, value: unknown, overrides: IConfigurationOverrides | IConfigurationUpdateOverrides, target: ConfigurationTarget, options?: IConfigurationUpdateOptions): Promise; + async updateValue(key: string, value: unknown, arg3?: any, arg4?: any, options?: any): Promise { const overrides: IConfigurationUpdateOverrides | undefined = isConfigurationUpdateOverrides(arg3) ? arg3 : isConfigurationOverrides(arg3) ? { resource: arg3.resource, overrideIdentifiers: arg3.overrideIdentifier ? [arg3.overrideIdentifier] : undefined } : undefined; const target: ConfigurationTarget | undefined = overrides ? arg4 : arg3; @@ -996,7 +996,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat return validWorkspaceFolders; } - private async writeConfigurationValue(key: string, value: any, target: ConfigurationTarget, overrides: IConfigurationUpdateOverrides | undefined, options?: IConfigurationUpdateOverrides): Promise { + private async writeConfigurationValue(key: string, value: unknown, target: ConfigurationTarget, overrides: IConfigurationUpdateOverrides | undefined, options?: IConfigurationUpdateOverrides): Promise { if (!this.instantiationService) { throw new Error('Cannot write configuration because the configuration service is not yet ready to accept writes.'); } @@ -1080,7 +1080,7 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat } } - private deriveConfigurationTargets(key: string, value: any, inspect: IConfigurationValue): ConfigurationTarget[] { + private deriveConfigurationTargets(key: string, value: unknown, inspect: IConfigurationValue): ConfigurationTarget[] { if (equals(value, inspect.value)) { return []; } diff --git a/src/vs/workbench/services/configuration/common/configurationEditing.ts b/src/vs/workbench/services/configuration/common/configurationEditing.ts index 18f3c329745..1cbb3f351a6 100644 --- a/src/vs/workbench/services/configuration/common/configurationEditing.ts +++ b/src/vs/workbench/services/configuration/common/configurationEditing.ts @@ -112,7 +112,7 @@ export class ConfigurationEditingError extends ErrorNoTelemetry { export interface IConfigurationValue { key: string; - value: any; + value: unknown; } export interface IConfigurationEditingOptions extends IConfigurationUpdateOptions { diff --git a/src/vs/workbench/services/configuration/common/jsonEditing.ts b/src/vs/workbench/services/configuration/common/jsonEditing.ts index 41481d442c7..0dcef249fb7 100644 --- a/src/vs/workbench/services/configuration/common/jsonEditing.ts +++ b/src/vs/workbench/services/configuration/common/jsonEditing.ts @@ -25,7 +25,7 @@ export class JSONEditingError extends Error { export interface IJSONValue { path: JSONPath; - value: any; + value: unknown; } export interface IJSONEditingService { diff --git a/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.ts b/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.ts index c192b3a38a7..2c96891407d 100644 --- a/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.ts @@ -143,14 +143,14 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR this.resolvableVariables.add('input'); } - override async resolveWithInteractionReplace(folder: IWorkspaceFolderData | undefined, config: any, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise { + override async resolveWithInteractionReplace(folder: IWorkspaceFolderData | undefined, config: unknown, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise { const parsed = ConfigurationResolverExpression.parse(config); await this.resolveWithInteraction(folder, parsed, section, variables, target); return parsed.toObject(); } - override async resolveWithInteraction(folder: IWorkspaceFolderData | undefined, config: any, section?: string, variableToCommandMap?: IStringDictionary, target?: ConfigurationTarget): Promise | undefined> { + override async resolveWithInteraction(folder: IWorkspaceFolderData | undefined, config: unknown, section?: string, variableToCommandMap?: IStringDictionary, target?: ConfigurationTarget): Promise | undefined> { const expr = ConfigurationResolverExpression.parse(config); // Get values for input variables from UI diff --git a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts index 333de5abbd7..15f7c61d9b6 100644 --- a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts +++ b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts @@ -34,13 +34,13 @@ export interface IConfigurationResolverService { * @param section For example, 'tasks' or 'debug'. Used for resolving inputs. * @param variables Aliases for commands. */ - resolveWithInteractionReplace(folder: IWorkspaceFolderData | undefined, config: any, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise; + resolveWithInteractionReplace(folder: IWorkspaceFolderData | undefined, config: unknown, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise; /** * Similar to resolveWithInteractionReplace, except without the replace. Returns a map of variables and their resolution. * Keys in the map will be of the format input:variableName or command:variableName. */ - resolveWithInteraction(folder: IWorkspaceFolderData | undefined, config: any, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise | undefined>; + resolveWithInteraction(folder: IWorkspaceFolderData | undefined, config: unknown, section?: string, variables?: IStringDictionary, target?: ConfigurationTarget): Promise | undefined>; /** * Contributes a variable that can be resolved later. Consumers that use resolveAny, resolveWithInteraction, diff --git a/src/vs/workbench/services/themes/common/themeConfiguration.ts b/src/vs/workbench/services/themes/common/themeConfiguration.ts index b4a84348fb7..09187c4940f 100644 --- a/src/vs/workbench/services/themes/common/themeConfiguration.ts +++ b/src/vs/workbench/services/themes/common/themeConfiguration.ts @@ -360,7 +360,7 @@ export class ThemeConfiguration { return ConfigurationTarget.USER; } - private async writeConfiguration(key: string, value: any, settingsTarget: ThemeSettingTarget): Promise { + private async writeConfiguration(key: string, value: unknown, settingsTarget: ThemeSettingTarget): Promise { if (settingsTarget === undefined || settingsTarget === 'preview') { return; }