-
Notifications
You must be signed in to change notification settings - Fork 36k
Remove any from terminal in server #276272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
anywithunknownfor untyped data in IPC channels and command execution contexts - Added default type parameter to
IProcessProperty<T>interface to make it more ergonomic - Introduced
ITraceRpcArgsinterface and improvedtraceRpcdecorator type safety with proper generic constraints - Updated event emitter types throughout the terminal codebase to remove explicit
anytype 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>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnProcessDataEvent: return (this._ptyHostService.onProcessData) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnProcessDataEvent: return this._ptyHostService.onProcessData 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>; | ||
| case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnProcessReadyEvent: return (this._ptyHostService.onProcessReady) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnProcessReadyEvent: return this._ptyHostService.onProcessReady 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>; | ||
| case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnProcessExitEvent: return (this._ptyHostService.onProcessExit) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnProcessExitEvent: return this._ptyHostService.onProcessExit 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>; | ||
| case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnProcessReplayEvent: return (this._ptyHostService.onProcessReplay) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnProcessReplayEvent: return this._ptyHostService.onProcessReplay 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>; | ||
| case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return (this._ptyHostService.onProcessOrphanQuestion) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnProcessOrphanQuestion: return this._ptyHostService.onProcessOrphanQuestion 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>; | ||
| case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnExecuteCommand: return (this.onExecuteCommand) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnExecuteCommand: return this.onExecuteCommand as Event<T>; |
| 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>; |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>
| case RemoteTerminalChannelEvent.OnDidChangeProperty: return (this._ptyHostService.onDidChangeProperty) as Event<T>; | |
| case RemoteTerminalChannelEvent.OnDidChangeProperty: return this._ptyHostService.onDidChangeProperty as Event<T>; |
| } | ||
|
|
||
| listen(_: any, event: RemoteTerminalChannelEvent, arg: any): Event<any> { | ||
| listen<T extends unknown>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> { |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
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>.
| listen<T extends unknown>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> { | |
| listen<T>(_: unknown, event: RemoteTerminalChannelEvent, _arg: unknown): Event<T> { |
Part of #274723
Merge first: