Skip to content

Conversation

@Tyriar
Copy link
Member

@Tyriar Tyriar commented Nov 8, 2025

@Tyriar Tyriar added this to the November 2025 milestone Nov 8, 2025
@Tyriar Tyriar self-assigned this Nov 8, 2025
Copilot AI review requested due to automatic review settings November 8, 2025 13:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances type safety across the terminal subsystem by replacing any types with more appropriate TypeScript types (unknown, proper generics, and specific type definitions). The changes enable the removal of several files from the eslint ignore list for the @typescript-eslint/no-explicit-any rule.

Key changes:

  • Replaced any with unknown for untyped data in IPC channels and command execution contexts
  • Added default type parameter to IProcessProperty<T> interface to make it more ergonomic
  • Introduced ITraceRpcArgs interface and improved traceRpc decorator type safety with proper generic constraints
  • Updated event emitter types throughout the terminal codebase to remove explicit any type parameters

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
eslint.config.js Removed 6 terminal-related files from @typescript-eslint/no-explicit-any exception list
src/vs/platform/terminal/common/terminal.ts Added default type parameter to IProcessProperty<T> and removed any from event types
src/vs/platform/terminal/node/ptyHostService.ts Removed any from onDidChangeProperty event type
src/vs/platform/terminal/node/ptyService.ts Introduced ITraceRpcArgs interface, improved traceRpc decorator signature, and updated event/map types
src/vs/platform/terminal/node/terminalProcess.ts Removed any from event emitter type and updated eslint disable comment with GitHub issue reference
src/vs/platform/terminal/node/windowsShellHelper.ts Changed traverseTree parameter from any to proper WindowsProcessTreeType.IProcessTreeNode | undefined
src/vs/server/node/remoteTerminalChannel.ts Replaced any with unknown throughout, added generic type parameter to listen method with type casts
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts Added type assertion to properly type the property value access

case RemoteTerminalChannelEvent.OnPtyHostUnresponsiveEvent: return (this._ptyHostService.onPtyHostUnresponsive || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnPtyHostResponsiveEvent: return (this._ptyHostService.onPtyHostResponsive || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnPtyHostRequestResolveVariablesEvent: return (this._ptyHostService.onPtyHostRequestResolveVariables || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onProcessData as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessDataEvent: return this._ptyHostService.onProcessData as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnPtyHostResponsiveEvent: return (this._ptyHostService.onPtyHostResponsive || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnPtyHostRequestResolveVariablesEvent: return (this._ptyHostService.onPtyHostRequestResolveVariables || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onProcessReady as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return this._ptyHostService.onProcessReady as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnPtyHostRequestResolveVariablesEvent: return (this._ptyHostService.onPtyHostRequestResolveVariables || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onProcessExit as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessExitEvent: return this._ptyHostService.onProcessExit as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onProcessReplay as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return this._ptyHostService.onProcessReplay as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onProcessOrphanQuestion as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return this._ptyHostService.onProcessOrphanQuestion as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>;
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>;
case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this.onExecuteCommand as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>;
case RemoteTerminalChannelEvent.OnExecuteCommand: return this.onExecuteCommand as Event<T>;

Copilot uses AI. Check for mistakes.
case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>;
case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>;
case RemoteTerminalChannelEvent.OnDidRequestDetach: return (this._ptyHostService.onDidRequestDetach || Event.None) as Event<T>;
case RemoteTerminalChannelEvent.OnDidChangeProperty: return (this._ptyHostService.onDidChangeProperty) as Event<T>;
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses in the type cast. Since there's no || Event.None fallback here, the parentheses can be removed: this._ptyHostService.onDidChangeProperty as Event<T>

Suggested change
case RemoteTerminalChannelEvent.OnDidChangeProperty: return (this._ptyHostService.onDidChangeProperty) as Event<T>;
case RemoteTerminalChannelEvent.OnDidChangeProperty: return this._ptyHostService.onDidChangeProperty as Event<T>;

Copilot uses AI. Check for mistakes.
}

listen(_: any, event: RemoteTerminalChannelEvent, arg: any): Event<any> {
listen<T extends unknown>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> {
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic constraint T extends unknown is redundant since all types extend unknown by definition. This can be simplified to just <T>.

Suggested change
listen<T extends unknown>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> {
listen<T>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants