Skip to content

cleanup any-usages#274732

Merged
jrieken merged 2 commits intomainfrom
joh/ministerial-lynx
Nov 3, 2025
Merged

cleanup any-usages#274732
jrieken merged 2 commits intomainfrom
joh/ministerial-lynx

Conversation

@jrieken
Copy link
Member

@jrieken jrieken commented Nov 3, 2025

Copilot AI review requested due to automatic review settings November 3, 2025 11:57
@jrieken jrieken enabled auto-merge (squash) November 3, 2025 11:57
@jrieken jrieken self-assigned this Nov 3, 2025
Tyriar
Tyriar previously approved these changes Nov 3, 2025
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 PR improves type safety by replacing loose any types with more precise TypeScript types across the VS Code extension host API and editor contribution modules.

Key changes:

  • Type guard functions now use unknown instead of any for input parameters, with additional runtime type checks where needed
  • Function return types and generic type parameters changed from any to unknown or specific types
  • toJSON() methods now have explicit return types instead of any
  • Metadata properties in notebook-related classes changed from Record<string, any> to Record<string, unknown>
  • Files removed from the ESLint no-any rule exemption list after cleanup

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
workspaceEdit.ts Updated notebook metadata parameters and toJSON return type
textEdit.ts Enhanced type guard with object check, updated toJSON return type
symbolInformation.ts Added explicit toJSON return type
snippetTextEdit.ts Changed type guard parameter to unknown
snippetString.ts Updated type guard and callback parameters to unknown
selection.ts Enhanced type guard with object check
range.ts Enhanced type guard with object check, fixed type casting, updated toJSON
position.ts Updated type guard parameter and toJSON return type
notebooks.ts Changed metadata types to Record<string, unknown> and type guard parameters
markdownString.ts Enhanced type guard with proper object validation and type assertions
location.ts Updated type guard parameter and toJSON return type
diagnostic.ts Updated type guard parameter and toJSON return type
suggestController.ts Changed Promise to Promise and Event.any type parameter
suggestCommitCharacters.ts Changed callback return type to unknown
suggestAlternatives.ts Changed callback return type to unknown
suggest.ts Removed unnecessary type parameter from Promise.reject, changed Promise array type
snippetParser.ts Changed brand property from any to undefined
referencesWidget.ts Updated callback and return types to unknown or specific types
referencesController.ts Added type assertions for OneReference, changed array types to unknown
format.ts Updated type guard parameter to unknown
eslint.config.js Removed cleaned-up files from no-any exemption list

if (!thing || typeof thing !== 'object') {
return false;
}
return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

This line is excessively long and repetitively casts 'thing' to 'vscode.MarkdownString' four times. Consider extracting the cast to a variable for better readability. For example: const obj = thing as vscode.MarkdownString; return obj.appendCodeblock && obj.appendMarkdown && obj.appendText && (obj.value !== undefined);

Suggested change
return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
const obj = thing as vscode.MarkdownString;
return obj.appendCodeblock && obj.appendMarkdown && obj.appendText && (obj.value !== undefined);

Copilot uses AI. Check for mistakes.
if (!thing || typeof thing !== 'object') {
return false;
}
return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The type guard checks for the existence of methods but doesn't verify they are functions. This could produce false positives if the properties exist but aren't callable. Add typeof checks: typeof obj.appendCodeblock === 'function' && typeof obj.appendMarkdown === 'function' && typeof obj.appendText === 'function'

Suggested change
return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
return typeof (thing as vscode.MarkdownString).appendCodeblock === 'function'
&& typeof (thing as vscode.MarkdownString).appendMarkdown === 'function'
&& typeof (thing as vscode.MarkdownString).appendText === 'function'
&& ((thing as vscode.MarkdownString).value !== undefined);

Copilot uses AI. Check for mistakes.
@jrieken jrieken merged commit 0ce8e5c into main Nov 3, 2025
28 checks passed
@jrieken jrieken deleted the joh/ministerial-lynx branch November 3, 2025 13:45
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 18, 2025
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