Skip to content

Comments

[Claude Code Web] remove more typescript any assertions#1553

Draft
bobular wants to merge 14 commits intoclaude/tighten-up-01VC5MTuCMsecPxLDsqo23TVfrom
claude/remove-typescript-any-assertions-01RrawsLfZKy3NYbvL6y3xaf
Draft

[Claude Code Web] remove more typescript any assertions#1553
bobular wants to merge 14 commits intoclaude/tighten-up-01VC5MTuCMsecPxLDsqo23TVfrom
claude/remove-typescript-any-assertions-01RrawsLfZKy3NYbvL6y3xaf

Conversation

@bobular
Copy link
Member

@bobular bobular commented Nov 20, 2025

Free credits got extended by a few days!

- Sticky.tsx: Use AddEventListenerOptions type annotation for passive event listeners (6 fixes)
- StrategyControls.tsx: Remove unnecessary assertion on innerRef prop
- WordCloudAnalysisController.tsx: Remove assertion on tags data by fixing Tag interface
- WordCloudAnalysis.tsx: Extend Tag interface with Record<string, string | number>

All changes compile cleanly and consumer sites verified.
- RecordUI.tsx: Use AddEventListenerOptions for passive scroll listener (2 fixes)
- CommonResultTable.tsx: Replace 'as any' with properly typed MesaSortObject assertion

The CommonResultTable fix uses a more specific type assertion to handle the complex
conditional type in MesaStateProps while maintaining type safety.
- RecordMainCategorySection.tsx: Replace 'as any' with specific WDK model types
  - Use AttributeField for attribute wdkReference
  - Use TableField for table wdkReference
  - Use JSX.IntrinsicElements for dynamic header elements
- AnswerTable.tsx: Replace 'as any' on defaultProps with properly typed assertion

All changes use more specific type assertions instead of 'as any' for better type safety.
- SingleFieldFilter.tsx: Replace 'as any' with 'React.ComponentType<any> | null'
  for dynamic component selection

Improves type safety by using a more specific type assertion for the
dynamically selected field component.
- MultiFieldFilter.tsx: Make TableRow extend Record<string, any>
- Types.ts: Make ValueCounts extend Record<string, any>
- Both: Add MesaColumn import for better type documentation

The Row types now properly extend Record<string, any> as required by Mesa
generics. The columns arrays still require 'as any' because the column
definitions use Mesa properties in non-standard ways (React elements for
name/helpText, arrays for renderHeading). Fixing those would require
extensive refactoring of the Mesa API usage.

This improves type safety at the Row level while documenting the remaining
type issues at the column definition level.
Fixed incorrect/incomplete Mesa type definitions in @veupathdb/coreui:
- MesaColumn.name: Changed from string to ReactNode (used directly in JSX)
- MesaColumn.helpText: Changed from string to ReactNode (used in JSX)
- MesaColumn.renderHeading: Added support for arrays of render functions
- MesaColumn.inline: Added missing boolean property

These type definitions were hand-written by a junior developer and didn't
match the actual Mesa implementation, which was revealed when removing
'as any' assertions.

Removed 'as any' assertions from wdk-client:
- MultiFieldFilter.tsx: Removed 'as any' from columns array
- MembershipField.tsx: Removed 'as any' from columns array

The types now correctly reflect how Mesa is actually used throughout the
codebase. All changes verified to compile cleanly.
Removed unnecessary type assertions:
- throttle/debounce/memoize (5 fixes): TypeScript correctly infers the return
  types of these lodash functions, so no assertion needed
- jQuery selectors (3 fixes): jQuery types correctly handle $(window) and
  $(node), removed unnecessary assertions

One assertion remains for $.plot() - this is the flot plotting library plugin
which jQuery type definitions don't include, so the assertion is appropriate.

Also improved defaultProps typing to use a more specific assertion instead of
'as any'.

All changes compile cleanly.
Replaced 'as any' with properly typed MesaSortObject assertion, following
the same pattern used in CommonResultTable.tsx. The conditional type is
correctly satisfied with the generic type parameter.
Removed prop spreading assertion from RecordTableSection by passing props directly to RecordTableDescription component, which only expects table, record, and recordClass props.
1. Exported UIState interface from Histogram.tsx
2. Updated HistogramFieldProps.activeFieldState to use proper intersection type: { summary: OntologyTermSummary } & UIState
3. Created ConvertedDistributionEntry type for properly typing the converted distribution with numeric values
4. Added dataCount?: number to HistogramFieldProps and conditionally render UnknownCount only when dataCount is available
5. Removed 'as any' assertions for:
   - uiState prop on Histogram component
   - distribution prop on Histogram component
   - UnknownCount component prop spreading

This follows the user's suggested approach of typing activeFieldState as an intersection type with UIState.
1. Removed dead code that checked for filter.selection property (2 assertions)
   - This property doesn't exist on RangeFilter type
   - Removed selectionTotal calculation and display
2. Fixed NumberField.tsx prop spreading to HistogramField (1 assertion)
   - Updated NumberFieldProps.activeFieldState to use UIState intersection type
   - Added required HistogramField props to NumberFieldProps interface
   - Made selectByDefault optional in HistogramFieldProps to match usage pattern
Replaced prop spreading to MultiFieldFilter and SingleFieldFilter with explicit prop passing.
- MultiFieldFilter: Pass required props explicitly, ensuring leafSummaries is present with type assertion
- SingleFieldFilter: Pass required props explicitly, ensuring summary is present with type assertion
- Both components receive proper typed activeFieldState objects based on runtime checks

The type assertions (non-any) are justified because:
1. For MultiFieldFilter: Only rendered when activeFieldState.leafSummaries exists (checked by condition)
2. For SingleFieldFilter: Only rendered when activeFieldState.summary exists (for non-multi fields)
Replaced object literal prop spreading with explicit props for CheckboxTree component.
- Removed unused ref callback (treeDomNode was assigned but never used)
- Added required selectedList and onSelectionChange props with empty defaults (unused since isSelectable=false)
- Converted all props from object literal spread to direct JSX props
@bobular bobular changed the base branch from main to claude/tighten-up-01VC5MTuCMsecPxLDsqo23TV November 20, 2025 00:45
1. RecordNavigationSection.tsx: Replaced CategoriesCheckboxTree prop spreading with explicit props
   - Added required selectedLeaves and onChange props with empty defaults (unused since isSelectable=false)

2. RecordUI.tsx: Removed 2 prop spreading assertions
   - RecordNavigationSection: Passed required props explicitly
   - RecordMainSection: Passed required props explicitly, removed unused ref callback

RecordTableSection and RecordTable HOC assertions kept as appropriate for HOC wrapping patterns per TS guide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants