Skip to content

Replace interface to type for every prop react #34

Closed

Description

@aek676
No description provided.

Activity

  1. pullfrog commented on Aug 13, 2026

    @pullfrog

    Plan: replace interface with type for React props

    The issue has no body, so I scoped it from the title: every React prop declaration in the workspace should be a type alias. I inventoried all interface declarations in tracked source (libs/ has zero; node_modules excluded).

    Current state

    apps/web is already inconsistent with itself — the three inner form components introduced in #32 use type, while every outer component still uses interface:

    // edit-line-item.tsx:25
    interface EditLineItemProps { … }
    // edit-line-item.tsx:63 — same file, different style
    type EditLineItemFormProps = { … };

    So this is a consistency cleanup that follows the direction the codebase already moved in.

    Milestone 1 — convert the 11 prop interfaces

    All 11 are plain, local (non-exported), and none use extends, so each is a two-line mechanical edit (interface X { → type X = {, closing } → };). No intersections needed, no call sites change.

    File Type
    apps/web/src/components/ui/money.tsx:5 MoneyProps
    apps/web/src/components/ui/form/currency-input.tsx:5 CurrencyInputProps
    apps/web/src/features/session/components/session-draft.tsx:12 ReviewLayoutProps
    apps/web/src/features/session/components/confirm-session-button.tsx:8 ConfirmSessionButtonProps
    apps/web/src/features/session/components/receipt-capture.tsx:87 CaptureViewProps
    apps/web/src/features/session/components/edit-receipt-total.tsx:24 EditReceiptTotalProps
    apps/web/src/features/session/line-item/components/add-line-item.tsx:24 AddLineItemProps
    apps/web/src/features/session/line-item/components/delete-line-item.tsx:19 DeleteLineItemProps
    apps/web/src/features/session/line-item/components/edit-line-item.tsx:25 EditLineItemProps
    apps/web/src/features/session/line-item/components/line-item-list.tsx:5 LineItemListProps
    apps/web/src/features/session/line-item/components/line-item-row.tsx:7 LineItemRowProps

    Keep the existing doc comment on MoneyProps.suffix and the React.ReactNode / React.RefObject member types verbatim.

    Explicitly out of scope

    • apps/web/src/app/router.tsx:7 — interface Register must stay an interface. It is a declare module '@tanstack/react-router' augmentation, and TypeScript declaration merging only works with interfaces. Converting it breaks typed routing.
    • apps/web/src/app/route-tree.gen.ts — generated by TanStack Router and already excluded from Biome via !**/*.gen.ts.
    • apps/api/src/env.d.ts (Env, also a global augmentation), apps/api/src/storage/object-storage.ts, apps/api/src/storage/gcs.ts — not React props.
    • Non-prop web types ReceiptTotals (features/session/utils/receipt-totals.ts:3) and CurrencyFormat (utils/money.ts:16) — not props. Worth folding in only if milestone 2 is adopted; otherwise leave them.

    Milestone 2 (optional) — enforce it so it does not drift back

    Biome 2.5.5 (the pinned version) ships style/useConsistentTypeDefinitions as a stable rule, so no nursery opt-in is needed. Adding it to the existing apps/web/** override in biome.json:

    "style": {
      "useConsistentTypeDefinitions": { "level": "error", "options": { "style": "type" } }
    }

    Two consequences to accept before taking this:

    1. It applies to all type definitions in apps/web, not just props — so ReceiptTotals and CurrencyFormat must be converted too.
    2. It flags interface Register in router.tsx, which cannot be converted. That needs a targeted suppression:
      // biome-ignore lint/style/useConsistentTypeDefinitions: module augmentation requires an interface

    Scope the override to apps/web/** only — a root-level rule would fail nx lint api on ObjectStorage, GcsObjectStorageOptions, and Env.

    If a one-line suppression in router.tsx is unwanted, skip milestone 2 and ship milestone 1 alone; the issue is labelled good first issue and the conversion stands on its own.

    Verification

    Only apps/web is touched, so the relevant gates are:

    bun nx tsc:typecheck web
    bun nx lint web
    bun nx run web:format:check   # not `nx format:check web` — that hits Nx's built-in and misreports
    bun nx build web
    

    Type-level no-op, so bun nx test web should pass unchanged. Note type aliases drop declaration merging and the implicit-index-signature behaviour interfaces have; neither is used by any of these 11, so there is no runtime or type-surface risk.

    Delivery

    One PR on pullfrog/34-props-type-aliases, one commit for milestone 1 and (if adopted) a second for milestone 2, so the enforcement change can be dropped independently in review.

    Pullfrog  | Implement plan ➔ | View workflow run | via Pullfrog | Using Claude Opus | 𝕏

  2. pullfrog commented on Aug 13, 2026

    @pullfrog

    Opened #35 on pullfrog/34-props-type-aliases, implementing both milestones as two separable commits.

    Commit 1 converts the 11 component prop declarations from interface to type — all were plain, local, and extends-free, so each was a two-line mechanical edit with no call-site changes. This aligns the outer components with the three inner form components from #32, which already used type.

    Commit 2 adds Biome's style/useConsistentTypeDefinitions (stable at the pinned 2.5.5) to the apps/web/** override so the convention cannot drift back. Two follow-ons were required and are included: ReceiptTotals and CurrencyFormat are converted since the rule covers all type definitions, and interface Register in app/router.tsx gets a targeted biome-ignore because it is a declare module augmentation and declaration merging only works with interfaces. I verified that suppression is load-bearing rather than dead — with it removed, biome lint errors and offers exactly the type Register = {…} fix that would break typed routing. The override is scoped to apps/web/**; a root-level rule would redden nx lint api.

    Verified with nx sync:check plus run-many -t lint format:check, tsc:typecheck web, run-many -t test, and build web — all passing, with lint web showing the same 6 pre-existing warnings as main and zero errors.

    Pullfrog  | View workflow run | via Pullfrog | Using Claude Opus | 𝕏

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions