Skip to content

Fix any cast in code actions#270068

Merged
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/assistant-flea
Oct 6, 2025
Merged

Fix any cast in code actions#270068
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/assistant-flea

Conversation

@mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Oct 6, 2025

For #269213

Copilot AI review requested due to automatic review settings October 6, 2025 17:37
@mjbvz mjbvz enabled auto-merge October 6, 2025 17:37
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 fixes a TypeScript type casting issue by removing an unsafe any cast and adding proper type checking. The change ensures type safety when modifying command arguments in the code action controller.

Key Changes

  • Replaces unsafe any cast with proper type checking using Array.isArray()
  • Removes the ESLint disable comment that was suppressing the no-any-casts rule

if (command.arguments && command.arguments.length >= 1) {
// eslint-disable-next-line local/code-no-any-casts
command.arguments[0] = { ...(command.arguments[0] as any), autoSend: false };
if (command.arguments && command.arguments.length >= 1 && Array.isArray(command.arguments[0])) {
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The type check Array.isArray(command.arguments[0]) is incorrect. The code is trying to spread command.arguments[0] as an object with { ...command.arguments[0], autoSend: false }, but arrays cannot be spread into objects this way. This should check if command.arguments[0] is an object instead.

Suggested change
if (command.arguments && command.arguments.length >= 1 && Array.isArray(command.arguments[0])) {
if (
command.arguments &&
command.arguments.length >= 1 &&
typeof command.arguments[0] === 'object' &&
command.arguments[0] !== null &&
!Array.isArray(command.arguments[0])
) {

Copilot uses AI. Check for mistakes.
@mjbvz mjbvz force-pushed the dev/mjbvz/assistant-flea branch from 3a39595 to 66a3043 Compare October 6, 2025 17:38
@vs-code-engineering vs-code-engineering bot added this to the October 2025 milestone Oct 6, 2025
@mjbvz mjbvz merged commit 5b597d7 into microsoft:main Oct 6, 2025
17 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 20, 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