Skip to content

Extend the Bounty type with optional UI fields to remove ad-hoc casts #211

Description

@Benjtalkshow

The UI reads several fields from bounty that aren't on the codegen BountyFieldsFragment: claimCount, maxParticipants, maxSlots, totalSlotsOccupied, milestones, contributorProgress, submissions, applications. Components and hooks work around this with inline casts like (bounty as { submissions?: Array<{ ... }> | null }) scattered everywhere. The casts drift in shape from one file to the next, and TypeScript can't help when one of them is wrong.

What to do

Define each of these as optional fields on the Bounty interface in types/bounty.ts. Most of them are already there; the gap is consistency. Specifically:

  • submissions?: BountySubmission[] | null
  • applications?: BountyApplication[] | null (add BountyApplication if missing)
  • claimCount?: number | null
  • maxParticipants?: number | null
  • maxSlots?: number | null
  • totalSlotsOccupied?: number | null
  • milestones?: Milestone[] | null
  • contributorProgress?: ContributorProgress[] | null

Where useBountyDetail already returns BountyFieldsFragment & Partial<Bounty>, that covers most call sites. The remaining ad-hoc casts in bounty-detail-client.tsx, bounty-detail-sidebar-cta.tsx, model4-maintainer-dashboard.tsx, and use-competition-join-state.ts should be removed in favor of the typed shape.

Acceptance criteria

  • No (bounty as { ... }) casts remaining in the bounty detail tree
  • pnpm tsc --noEmit and pnpm lint pass
  • No behavioral change

Files

  • types/bounty.ts
  • components/bounty-detail/bounty-detail-client.tsx
  • components/bounty-detail/bounty-detail-sidebar-cta.tsx
  • components/bounty-detail/model4-maintainer-dashboard.tsx
  • hooks/use-competition-join-state.ts

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions