Skip to content

Type the search command cache walker and drop the two as any casts #277

Description

@Benjtalkshow

components/search-command.tsx:90 and :106 use as any to walk the React Query cache and pull bounty objects out of nested response shapes:

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const record = obj as any;
// ...
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const proj = bounty.project as any;

The cast hides which shapes the walker actually handles (BountiesQuery, infinite-query pages, raw arrays, nested project records) and the ESLint disable comments are a code smell.

What to do

  • Define a CacheRecord union covering the shapes extractFromObject actually traverses (e.g. BountyFieldsFragment | { bounties: { bounties: BountyFieldsFragment[] } } | { data: BountyFieldsFragment[] } | { pages: ... })
  • Use type predicates (function isBountyFragment(obj: unknown): obj is BountyFieldsFragment) instead of duck-typing with as any
  • Drop both eslint-disable comments

Acceptance criteria

  • No as any or eslint-disable for no-explicit-any in search-command.tsx
  • Same runtime behavior, Cmd+K still finds cached bounties and projects
  • pnpm tsc --noEmit and pnpm lint pass

Files

  • components/search-command.tsx

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions