Skip to content

Frontend: Inertia page props are hand-typed and force-cast (44 as unknown as) #505

Closed

Description

@antosubash

Tier 2: structural

Problem

There are 44 as unknown as casts and 42 usePage<{ props: X }>() calls, usually followed by .props as unknown as X. Examples: host/client_app/pages/Admin.tsx:55, Landing.tsx:41, modules/api_tokens/.../Admin.tsx:23, modules/background_tasks/.../Index.tsx:73.

A double cast turns type checking off. If a Python view renames a prop, tsc still passes and the page breaks at runtime. Nothing checks that a page's prop type matches what inertia.render(...) passes.

Proposal

  • Short term: add a usePageProps<T>() helper to packages/ui and remove the double casts.
  • Proper fix: have each view declare its props as a SQLModel DTO, then generate a PageProps map (page name → props type) at gen-pages time, as is already done for the page manifest. SM003/SM004 already link page names to renders, so the hook point exists.

Depends on or pairs with the typed API client issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions