Skip to content

Reduce use of explicit any type (#274723)#279751

Merged
bpasero merged 1 commit into
mainfrom
ben/pale-beetle
Nov 27, 2025
Merged

Reduce use of explicit any type (#274723)#279751
bpasero merged 1 commit into
mainfrom
ben/pale-beetle

Conversation

@bpasero
Copy link
Copy Markdown
Contributor

@bpasero bpasero commented Nov 27, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 27, 2025 08:09
@bpasero bpasero enabled auto-merge (squash) November 27, 2025 08:09
@bpasero bpasero self-assigned this Nov 27, 2025
@vs-code-engineering vs-code-engineering Bot added this to the November 2025 milestone Nov 27, 2025
Copy link
Copy Markdown
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 PR improves type safety across the codebase by systematically replacing explicit any types with more specific types (unknown, void, proper Electron types, and concrete type definitions). This allows these files to be removed from the ESLint exception list that permits any usage.

Key Changes

  • Replaced any with unknown for external/unvalidated data parameters (cached data, deserialization, type guards)
  • Changed Promise return types from Promise<any> to Promise<void> or Promise<unknown> as appropriate
  • Added proper Electron namespace types (Electron.Debugger, Electron.Event) in electron-main code
  • Replaced inline type definitions with concrete types (e.g., Record<string, string>)
  • Removed unnecessary type assertions and ESLint disable comments where TypeScript inference now works correctly

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/contrib/search/common/cacheState.ts Changed loadFn parameter type from Promise<any> to Promise<unknown> for cache loading function
src/vs/workbench/contrib/search/browser/searchWidget.ts Updated run() and triggerReplaceAll() return types from Promise<any> to Promise<void>, removed unnecessary Promise.resolve(null)
src/vs/workbench/contrib/notebook/common/notebookRange.ts Changed type guard parameter from any to unknown and replaced old-style casts with as assertions
src/vs/workbench/contrib/markers/browser/markersTable.ts Replaced generic any types with MarkerTableItem in virtual delegate, removed unnecessary type cast in filter
src/vs/workbench/contrib/chat/common/chatModes.ts Changed cached modes deserialization parameter from any to unknown
src/vs/platform/diagnostics/node/diagnosticsService.ts Replaced any with Record<string, string> for GPU features object
src/vs/platform/browserElements/electron-main/nativeBrowserElementsMainService.ts Added proper Electron.Debugger and Electron.Event types, defined inline type for matched styles structure, removed unnecessary type annotations in arrow functions
eslint.config.js Removed 7 files from the any usage exception list now that they no longer use explicit any types

}

formatMatchedStyles(matched: any): string {
formatMatchedStyles(matched: { inlineStyle?: { cssProperties?: Array<{ name: string; value: string }> }; matchedCSSRules?: Array<{ rule: { selectorList: { selectors: Array<{ text: string }> }; origin: string; style: { cssProperties: Array<{ name: string; value: string }> } } }>; inherited?: Array<{ matchedCSSRules?: Array<{ rule: { selectorList: { selectors: Array<{ text: string }> }; origin: string; style: { cssProperties: Array<{ name: string; value: string }> } } }> }> }): string {
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

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

The inline type definition for the matched parameter is extremely long and complex (over 300 characters on a single line), which makes it difficult to read and maintain. Consider extracting this into a separate interface or type alias above the function, such as:

interface MatchedStylesData {
  inlineStyle?: { cssProperties?: Array<{ name: string; value: string }> };
  matchedCSSRules?: Array<{ 
    rule: { 
      selectorList: { selectors: Array<{ text: string }> }; 
      origin: string; 
      style: { cssProperties: Array<{ name: string; value: string }> }
    } 
  }>;
  inherited?: Array<{ 
    matchedCSSRules?: Array<{ 
      rule: { 
        selectorList: { selectors: Array<{ text: string }> }; 
        origin: string; 
        style: { cssProperties: Array<{ name: string; value: string }> } 
      } 
    }> 
  }>;
}

formatMatchedStyles(matched: MatchedStylesData): string {

This would improve readability and make the type reusable if needed elsewhere.

Suggested change
formatMatchedStyles(matched: { inlineStyle?: { cssProperties?: Array<{ name: string; value: string }> }; matchedCSSRules?: Array<{ rule: { selectorList: { selectors: Array<{ text: string }> }; origin: string; style: { cssProperties: Array<{ name: string; value: string }> } } }>; inherited?: Array<{ matchedCSSRules?: Array<{ rule: { selectorList: { selectors: Array<{ text: string }> }; origin: string; style: { cssProperties: Array<{ name: string; value: string }> } } }> }> }): string {
/**
* Structure representing matched CSS styles data.
*/
interface MatchedStylesData {
inlineStyle?: { cssProperties?: Array<{ name: string; value: string }> };
matchedCSSRules?: Array<{
rule: {
selectorList: { selectors: Array<{ text: string }> };
origin: string;
style: { cssProperties: Array<{ name: string; value: string }> };
};
}>;
inherited?: Array<{
matchedCSSRules?: Array<{
rule: {
selectorList: { selectors: Array<{ text: string }> };
origin: string;
style: { cssProperties: Array<{ name: string; value: string }> };
};
}>;
}>;
}
formatMatchedStyles(matched: MatchedStylesData): string {

Copilot uses AI. Check for mistakes.
@bpasero bpasero merged commit a2ad562 into main Nov 27, 2025
43 of 45 checks passed
@bpasero bpasero deleted the ben/pale-beetle branch November 27, 2025 08:56
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jan 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants