Skip to content

[scanner] fix: replace 'any' types with proper type annotations#19862

Merged
clubanderson merged 3 commits into
mainfrom
scanner/fix-19856
Jun 28, 2026
Merged

[scanner] fix: replace 'any' types with proper type annotations#19862
clubanderson merged 3 commits into
mainfrom
scanner/fix-19856

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #19856

Replaces 25 uses of the any type with proper type annotations to improve type safety.

Changes

Test files (using specific interfaces and proper types):

  • EnterpriseSidebar.test.tsx: Mock component props with interfaces
  • EnterpriseLayout.test.tsx: Mock customizer props with interface
  • ClusterGrid.common.test.tsx: React.KeyboardEvent types for event handlers
  • CreateDashboardModal.test.tsx: Specific modal props interfaces
  • ui-data-components.test.tsx: Removed unnecessary any casts
  • WorkloadsExtended.test.tsx: Proper mock data interfaces

Production code:

  • VClusterActionBanner.tsx: Removed any cast for i18n translation keys

Replaces 25 uses of the 'any' type with proper type annotations to improve type safety:

Test files (using specific interfaces and unknown):
- EnterpriseSidebar.test.tsx: Mock component props with interfaces
- EnterpriseLayout.test.tsx: Mock customizer props with interface
- ClusterGrid.common.test.tsx: React.KeyboardEvent types for event handlers
- CreateDashboardModal.test.tsx: Specific modal props interfaces
- ui-data-components.test.tsx: Removed unnecessary 'any' casts
- WorkloadsExtended.test.tsx: Proper mock data interfaces

Production code:
- VClusterActionBanner.tsx: Removed 'any' cast for i18n translation keys

All changes maintain existing functionality while improving type safety.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 28, 2026 21:37
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit d1471dc
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a419d24b647ea0008b56472
😎 Deploy Preview https://deploy-preview-19862.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/2-standard labels Jun 28, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Check

All new source files in this PR have corresponding test files.

Checked web/src/hooks/ and web/src/components/ against origin/main.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses issue #19856 by improving TypeScript type-safety, primarily in tests, by replacing any usages with explicit interfaces/types and safer casts, and by removing unnecessary any casts in production i18n calls.

Changes:

  • Replaced any in multiple test mocks/fixtures with explicit interfaces and more specific event/argument typings.
  • Removed any casts around i18n translation key usage in VClusterActionBanner.
  • Tightened mock signatures (e.g., unknown[], generic identity functions) to reduce implicit any usage.

Build/lint are expected to be validated by CI on the PR.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
web/src/components/workloads/tests/WorkloadsExtended.test.tsx Replaces any arrays and mock signatures with interfaces/generics/unknown[]; adjusts useGlobalFilters mocks.
web/src/components/settings/sections/VClusterActionBanner.tsx Removes any casts on i18n translation key calls.
web/src/components/mission-control/tests/ui-data-components.test.tsx Removes any casts in component props, aiming for type-correct test inputs.
web/src/components/enterprise/tests/EnterpriseSidebar.test.tsx Adds typed mock props for SidebarShell and removes any in iteration.
web/src/components/enterprise/tests/EnterpriseLayout.test.tsx Adds typed mock props for DashboardCustomizer.
web/src/components/dashboard/tests/CreateDashboardModal.test.tsx Adds typed mock props for modal header/footer and removes any casts.
web/src/components/clusters/components/tests/ClusterGrid.common.test.tsx Replaces any casts with React.KeyboardEvent-typed casts for handlers.

Comment on lines 222 to +227
assignment={{
clusterName: 'eks-prod',
projectNames: ['falco'],
readiness: { overallScore: 85, cpuHeadroomPercent: 75, memHeadroomPercent: 75, storageHeadroomPercent: 100 },
warnings: []
} as unknown as any}
}}
Comment on lines 242 to +248
availableProjects={['falco']}
assignment={{
clusterName: 'eks-prod',
projectNames: [],
readiness: { overallScore: 85 },
warnings: []
} as unknown as any}
}}
Comment on lines 392 to 397
onAddProject={vi.fn()}
onRemoveProject={vi.fn()}
onUpdatePriority={vi.fn()}
aiStreaming={true}
planningMission={{ status: 'running', messages: [] } as unknown as any}
planningMission={{ status: 'running', messages: [] }}
/>
Comment on lines 167 to +172
vi.mocked(useGlobalFilters).mockReturnValue({
selectedClusters: [],
isAllClustersSelected: true,
customFilter: 'nginx',
filterByCluster: (items: any[]) => items,
} as any)
filterByCluster: <T,>(items: T[]) => items,
})
Comment on lines 254 to +259
vi.mocked(useGlobalFilters).mockReturnValue({
selectedClusters: [],
isAllClustersSelected: true,
customFilter: '',
filterByCluster: (items: any[]) => items,
} as any)
filterByCluster: <T,>(items: T[]) => items,
})
Comment on lines 461 to +466
vi.mocked(useGlobalFilters).mockReturnValue({
selectedClusters: [],
isAllClustersSelected: true,
customFilter: '',
filterByCluster: (items: any[]) => items,
} as any)
filterByCluster: <T,>(items: T[]) => items,
})
…anner

Dynamic translation keys built at runtime cannot match the static
union of known keys, so `as any` is the necessary escape hatch.
The other 24 `any` removals in test files remain — this only
restores the 2 production-code assertions that broke the build.

Signed-off-by: clubanderson <andy@kubestellar.io>
@clubanderson clubanderson merged commit b6641d6 into main Jun 28, 2026
35 of 42 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-19856 branch June 28, 2026 22:33
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit b6641d6eb7309df2759ae4d3aff706f9b947ae74.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: b6641d6eb7309df2759ae4d3aff706f9b947ae74
Specs run: Clusters.spec.ts Dashboard.spec.ts Settings.spec.ts smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/28338271655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auto-QA] 25 uses of 'any' type reduce type safety

2 participants