From 1379c694f57cf388b7360e69950ccf211e85185c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 10 Nov 2025 05:27:15 -0800 Subject: [PATCH] Remove any from contrib/terminal|terminalContrib Part of #274723 --- eslint.config.js | 11 ----------- .../browser/terminalConfigurationService.ts | 7 ++++--- .../terminal/browser/terminalExtensions.ts | 2 +- .../terminal/browser/terminalInstance.ts | 16 ++++++++-------- .../browser/terminalProcessExtHostProxy.ts | 17 +++++++++-------- .../terminal/browser/terminalProcessManager.ts | 2 +- .../browser/terminalProfileQuickpick.ts | 2 +- .../terminal/browser/terminalProfileService.ts | 2 +- .../terminal/browser/xterm/xtermTerminal.ts | 10 ++++++---- .../contrib/terminal/common/basePty.ts | 16 +++++++++------- .../contrib/terminal/common/terminal.ts | 4 ++-- .../suggest/browser/terminalSuggestAddon.ts | 3 +-- 12 files changed, 43 insertions(+), 49 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 9ad4c2fc3e9..1ff0004c3ad 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -902,18 +902,7 @@ export default tseslint.config( 'src/vs/workbench/contrib/tasks/common/taskSystem.ts', 'src/vs/workbench/contrib/tasks/common/tasks.ts', 'src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts', - 'src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts', - 'src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts', - 'src/vs/workbench/contrib/terminal/common/basePty.ts', 'src/vs/workbench/contrib/terminal/common/remote/remoteTerminalChannel.ts', - 'src/vs/workbench/contrib/terminal/common/terminal.ts', - 'src/vs/workbench/contrib/terminalContrib/links/browser/links.ts', - 'src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts', 'src/vs/workbench/contrib/testing/browser/testExplorerActions.ts', 'src/vs/workbench/contrib/testing/browser/testingExplorerView.ts', 'src/vs/workbench/contrib/testing/common/storedValue.ts', diff --git a/src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts b/src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts index d39f1a91159..c93bb1a33e6 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalConfigurationService.ts @@ -13,6 +13,7 @@ import type { IXtermCore } from './xterm-private.js'; import { DEFAULT_BOLD_FONT_WEIGHT, DEFAULT_FONT_WEIGHT, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, FontWeight, ITerminalConfiguration, MAXIMUM_FONT_WEIGHT, MINIMUM_FONT_WEIGHT, MINIMUM_LETTER_SPACING, TERMINAL_CONFIG_SECTION, type ITerminalFont } from '../common/terminal.js'; import { isMacintosh } from '../../../../base/common/platform.js'; import { TerminalLocation, TerminalLocationConfigValue } from '../../../../platform/terminal/common/terminal.js'; +import { isString } from '../../../../base/common/types.js'; // #region TerminalConfigurationService @@ -60,7 +61,7 @@ export class TerminalConfigurationService extends Disposable implements ITermina this._onConfigChanged.fire(); } - private _normalizeFontWeight(input: any, defaultWeight: FontWeight): FontWeight { + private _normalizeFontWeight(input: FontWeight, defaultWeight: FontWeight): FontWeight { if (input === 'normal' || input === 'bold') { return input; } @@ -244,8 +245,8 @@ export class TerminalFontMetrics extends Disposable { // #region Utils -function clampInt(source: any, minimum: number, maximum: number, fallback: T): number | T { - let r = parseInt(source, 10); +function clampInt(source: string | number, minimum: number, maximum: number, fallback: T): number | T { + let r = isString(source) ? parseInt(source, 10) : source; if (isNaN(r)) { return fallback; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts b/src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts index d37dcbd684d..613d73281ac 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalExtensions.ts @@ -41,7 +41,7 @@ export type ITerminalContributionDescription = { readonly id: string } & ( */ export function registerTerminalContribution(id: string, ctor: { new(ctx: ITerminalContributionContext, ...services: Services): ITerminalContribution }, canRunInDetachedTerminals?: false): void; export function registerTerminalContribution(id: string, ctor: { new(ctx: IDetachedCompatibleTerminalContributionContext, ...services: Services): ITerminalContribution }, canRunInDetachedTerminals: true): void; -export function registerTerminalContribution(id: string, ctor: { new(ctx: any, ...services: Services): ITerminalContribution }, canRunInDetachedTerminals: boolean = false): void { +export function registerTerminalContribution(id: string, ctor: TerminalContributionCtor | DetachedCompatibleTerminalContributionCtor, canRunInDetachedTerminals: boolean = false): void { // eslint-disable-next-line local/code-no-dangerous-type-assertions TerminalContributionRegistry.INSTANCE.registerTerminalContribution({ id, ctor, canRunInDetachedTerminals } as ITerminalContributionDescription); } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 7444f249616..6fdfdb320e9 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1468,36 +1468,36 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._register(processManager.onDidChangeProperty(({ type, value }) => { switch (type) { case ProcessPropertyType.Cwd: - this._cwd = value; + this._cwd = value as IProcessPropertyMap[ProcessPropertyType.Cwd]; this._labelComputer?.refreshLabel(this); break; case ProcessPropertyType.InitialCwd: - this._initialCwd = value; + this._initialCwd = value as IProcessPropertyMap[ProcessPropertyType.InitialCwd]; this._cwd = this._initialCwd; this._setTitle(this.title, TitleEventSource.Config); this._icon = this._shellLaunchConfig.attachPersistentProcess?.icon || this._shellLaunchConfig.icon; this._onIconChanged.fire({ instance: this, userInitiated: false }); break; case ProcessPropertyType.Title: - this._setTitle(value ?? '', TitleEventSource.Process); + this._setTitle(value as IProcessPropertyMap[ProcessPropertyType.Title] ?? '', TitleEventSource.Process); break; case ProcessPropertyType.OverrideDimensions: - this.setOverrideDimensions(value, true); + this.setOverrideDimensions(value as IProcessPropertyMap[ProcessPropertyType.OverrideDimensions], true); break; case ProcessPropertyType.ResolvedShellLaunchConfig: - this._setResolvedShellLaunchConfig(value); + this._setResolvedShellLaunchConfig(value as IProcessPropertyMap[ProcessPropertyType.ResolvedShellLaunchConfig]); break; case ProcessPropertyType.ShellType: - this.setShellType(value); + this.setShellType(value as IProcessPropertyMap[ProcessPropertyType.ShellType]); break; case ProcessPropertyType.HasChildProcesses: - this._onDidChangeHasChildProcesses.fire(value); + this._onDidChangeHasChildProcesses.fire(value as IProcessPropertyMap[ProcessPropertyType.HasChildProcesses]); break; case ProcessPropertyType.UsedShellIntegrationInjection: this._usedShellIntegrationInjection = true; break; case ProcessPropertyType.ShellIntegrationInjectionFailureReason: - this._shellIntegrationInjectionInfo = value; + this._shellIntegrationInjectionInfo = value as IProcessPropertyMap[ProcessPropertyType.ShellIntegrationInjectionFailureReason]; break; } })); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts index 3f25d0aaf70..aa01dfe24df 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts @@ -34,7 +34,7 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal readonly onRequestInitialCwd: Event = this._onRequestInitialCwd.event; private readonly _onRequestCwd = this._register(new Emitter()); readonly onRequestCwd: Event = this._onRequestCwd.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter()); readonly onDidChangeProperty = this._onDidChangeProperty.event; private readonly _onProcessExit = this._register(new Emitter()); readonly onProcessExit: Event = this._onProcessExit.event; @@ -63,22 +63,22 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal this._onProcessReady.fire({ pid, cwd, windowsPty: undefined }); } - emitProcessProperty({ type, value }: IProcessProperty): void { + emitProcessProperty({ type, value }: IProcessProperty): void { switch (type) { case ProcessPropertyType.Cwd: - this.emitCwd(value); + this.emitCwd(value as IProcessPropertyMap[ProcessPropertyType.Cwd]); break; case ProcessPropertyType.InitialCwd: - this.emitInitialCwd(value); + this.emitInitialCwd(value as IProcessPropertyMap[ProcessPropertyType.InitialCwd]); break; case ProcessPropertyType.Title: - this.emitTitle(value); + this.emitTitle(value as IProcessPropertyMap[ProcessPropertyType.Title]); break; case ProcessPropertyType.OverrideDimensions: - this.emitOverrideDimensions(value); + this.emitOverrideDimensions(value as IProcessPropertyMap[ProcessPropertyType.OverrideDimensions]); break; case ProcessPropertyType.ResolvedShellLaunchConfig: - this.emitResolvedShellLaunchConfig(value); + this.emitResolvedShellLaunchConfig(value as IProcessPropertyMap[ProcessPropertyType.ResolvedShellLaunchConfig]); break; } } @@ -163,8 +163,9 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal }); } - async refreshProperty(type: T): Promise { + async refreshProperty(type: T): Promise { // throws if called in extHostTerminalService + throw new Error('refreshProperty not implemented on extension host'); } async updateProperty(type: T, value: IProcessPropertyMap[T]): Promise { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index e637972e608..b89718dd5ff 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -117,7 +117,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce readonly onProcessData = this._onProcessData.event; private readonly _onProcessReplayComplete = this._register(new Emitter()); readonly onProcessReplayComplete = this._onProcessReplayComplete.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter()); readonly onDidChangeProperty = this._onDidChangeProperty.event; private readonly _onEnvironmentVariableInfoChange = this._register(new Emitter()); readonly onEnvironmentVariableInfoChanged = this._onEnvironmentVariableInfoChange.event; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts index 5b4bc57c92a..998a838a7f0 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts @@ -112,7 +112,7 @@ export class TerminalProfileQuickpick { if (hasKey(context.item.profile, { id: true })) { return; } - const configProfiles: { [key: string]: any } = this._configurationService.getValue(TerminalSettingPrefix.Profiles + platformKey); + const configProfiles: { [key: string]: ITerminalExecutable } = this._configurationService.getValue(TerminalSettingPrefix.Profiles + platformKey); const existingProfiles = !!configProfiles ? Object.keys(configProfiles) : []; const name = await this._quickInputService.input({ prompt: nls.localize('enterTerminalProfileName', "Enter terminal profile name"), diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts b/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts index ead592e0bcd..33f7daa40b7 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts @@ -169,7 +169,7 @@ export class TerminalProfileService extends Disposable implements ITerminalProfi private async _updateContributedProfiles(): Promise { const platformKey = await this.getPlatformKey(); const excludedContributedProfiles: string[] = []; - const configProfiles: { [key: string]: any } = this._configurationService.getValue(TerminalSettingPrefix.Profiles + platformKey); + const configProfiles: { [key: string]: ITerminalExecutable } = this._configurationService.getValue(TerminalSettingPrefix.Profiles + platformKey); for (const [profileName, value] of Object.entries(configProfiles)) { if (value === null) { excludedContributedProfiles.push(profileName); diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index 90a4467f7db..a6869fe4e98 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -741,11 +741,13 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach if (this.hasSelection() || (asHtml && command)) { if (asHtml) { const textAsHtml = await this.getSelectionAsHtml(command); - function listener(e: any) { - if (!e.clipboardData.types.includes('text/plain')) { - e.clipboardData.setData('text/plain', command?.getOutput() ?? ''); + function listener(e: ClipboardEvent) { + if (e.clipboardData) { + if (!e.clipboardData.types.includes('text/plain')) { + e.clipboardData.setData('text/plain', command?.getOutput() ?? ''); + } + e.clipboardData.setData('text/html', textAsHtml); } - e.clipboardData.setData('text/html', textAsHtml); e.preventDefault(); } const doc = dom.getDocument(this.raw.element); diff --git a/src/vs/workbench/contrib/terminal/common/basePty.ts b/src/vs/workbench/contrib/terminal/common/basePty.ts index a851f56225e..2d58dadb1a4 100644 --- a/src/vs/workbench/contrib/terminal/common/basePty.ts +++ b/src/vs/workbench/contrib/terminal/common/basePty.ts @@ -37,7 +37,7 @@ export abstract class BasePty extends Disposable implements Partial()); readonly onProcessReady = this._onProcessReady.event; - protected readonly _onDidChangeProperty = this._register(new Emitter>()); + protected readonly _onDidChangeProperty = this._register(new Emitter()); readonly onDidChangeProperty = this._onDidChangeProperty.event; protected readonly _onProcessExit = this._register(new Emitter()); readonly onProcessExit = this._onProcessExit.event; @@ -68,18 +68,20 @@ export abstract class BasePty extends Disposable implements Partial) { + handleDidChangeProperty({ type, value }: IProcessProperty) { switch (type) { case ProcessPropertyType.Cwd: - this._properties.cwd = value; + this._properties.cwd = value as IProcessPropertyMap[ProcessPropertyType.Cwd]; break; case ProcessPropertyType.InitialCwd: - this._properties.initialCwd = value; + this._properties.initialCwd = value as IProcessPropertyMap[ProcessPropertyType.InitialCwd]; break; - case ProcessPropertyType.ResolvedShellLaunchConfig: - if (value.cwd && typeof value.cwd !== 'string') { - value.cwd = URI.revive(value.cwd); + case ProcessPropertyType.ResolvedShellLaunchConfig: { + const cast = value as IProcessPropertyMap[ProcessPropertyType.ResolvedShellLaunchConfig]; + if (cast.cwd && typeof cast.cwd !== 'string') { + cast.cwd = URI.revive(cast.cwd); } + } } this._onDidChangeProperty.fire({ type, value }); } diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index 45d392f1aae..3028e1afaa2 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -288,7 +288,7 @@ export interface ITerminalProcessManager extends IDisposable, ITerminalProcessIn readonly onProcessData: Event; readonly onProcessReplayComplete: Event; readonly onEnvironmentVariableInfoChanged: Event; - readonly onDidChangeProperty: Event>; + readonly onDidChangeProperty: Event; readonly onProcessExit: Event; readonly onRestoreCommands: Event; @@ -336,7 +336,7 @@ export interface ITerminalProcessExtHostProxy extends IDisposable { readonly instanceId: number; emitData(data: string): void; - emitProcessProperty(property: IProcessProperty): void; + emitProcessProperty(property: IProcessProperty): void; emitReady(pid: number, cwd: string, windowsPty: IProcessReadyWindowsPty | undefined): void; emitExit(exitCode: number | undefined): void; diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts index 2213c0a1096..4dbaec1756c 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts @@ -786,7 +786,6 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest private _ensureSuggestWidget(terminal: Terminal): SimpleSuggestWidget { if (!this._suggestWidget) { - // eslint-disable-next-line local/code-no-any-casts this._suggestWidget = this._register(this._instantiationService.createInstance( SimpleSuggestWidget, this._container!, @@ -799,7 +798,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest this._getFontInfo.bind(this), this._onDidFontConfigurationChange.event.bind(this), this._getAdvancedExplainModeDetails.bind(this) - )) as any as SimpleSuggestWidget; + )) as unknown as SimpleSuggestWidget; this._register(this._suggestWidget.onDidSelect(async e => this.acceptSelectedSuggestion(e))); this._register(this._suggestWidget.onDidHide(() => this._terminalSuggestWidgetVisibleContextKey.reset())); this._register(this._suggestWidget.onDidShow(() => this._terminalSuggestWidgetVisibleContextKey.set(true)));