Skip to content

[Refactor] Pay down TypeScript type-safety debt — 575 errors across 89 files (tsc --noEmit) #11

Description

@seneka-DSNA

Context

next.config.mjs ignores build type errors (ignoreBuildErrors: true), and nobody had
run tsc --noEmit in isolation until it was added to CI. That's why 575 errors across
89 files showed up all at once — pre-existing debt, not something new. The CI step is
currently non-blocking (continue-on-error: true) because of this backlog. Missing
imports (FormEvent, useEffect, etc.) are already being handled separately.

Priority 1 — Real bugs, not just missing types ✅ FIXED

  • DashboardClient.tsx:44-70 — calls setter functions (setData, setLoading, etc.)
    never destructured from useState. Throws at runtime if hit.
  • datatable.tsx:349 — comparing a boolean to a string, can never be true.
  • InvoiceTable.tsx:217, CropImage.tsx:28, TotalEarning.tsx:2 — broken component
    return type, wrong function signature, and a broken import path, respectively.
  • .../untitled folder/Datatable.tsx:33 — imports a file that doesn't exist (this
    folder looks like dead/duplicate code — candidate for deletion, not fixing).

Priority 2 — Bulk type hygiene (~380 instances, low risk)

Mostly implicit any on parameters, and session.user.role/id not recognized because
next-auth's Session type was never extended to match the custom fields added in the
jwt/session callbacks (data is real at runtime, only the type declaration is
missing). Not worth fixing one-by-one — see approach below.

Suggested approach

  1. Review and fix Priority 1 individually. DONE ✅
  2. For Priority 2: add a types/next-auth.d.ts augmentation (fixes the role/id
    cluster in one shot), then either fix the rest incrementally or mark untouched
    legacy files // @ts-nocheck so new files stay strictly checked.
  3. Once npm run typecheck is clean, remove continue-on-error from CI and
    ignoreBuildErrors from next.config.mjs.

Definition of done

npm run typecheck exits 0 (or remaining files are explicitly @ts-nocheck'd), and
CI's Type Check step is blocking again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions