Skip to content

Upgrade TypeScript from 4.6 to 5.x #6919

@talissoncosta

Description

@talissoncosta

Problem

The frontend uses TypeScript 4.6.4 (released March 2022). Newer tooling increasingly assumes >= 4.9 or 5.x, and staying on 4.6 creates growing friction.

Risks of staying on 4.6

  • Missing language featuressatisfies (4.9), const type parameters (5.0), decorators (5.0), using declarations (5.2) are all unavailable. Contributors familiar with modern TS will hit friction.
  • Weaker type inference — each TS release tightens inference, narrowing, and control flow analysis. Staying on 4.6 means we miss bug-catching improvements the compiler could give us for free.
  • Security and bug fixes — TS 4.6 is no longer maintained. No patches for compiler bugs or security issues.
  • Ecosystem drift@types/* packages and libraries increasingly assume >= 4.9 or 5.x. We already see this with @sinclair/typebox (Storybook dep) failing typecheck because it uses syntax introduced after 4.6.
  • Storybook upgrade blocked — upgrading to Storybook 10+ requires TypeScript >= 4.9. We reverted to Storybook 8 (chore: design system colour tokens, primitives & Storybook #6883) specifically because of this constraint.

Scope estimate

A trial upgrade to 4.9 surfaced ~805 type errors, mostly from stricter checks. Upgrading to 5.x will likely surface more. This should be treated as a dedicated effort, not bundled with other work.

Proposed fix

Upgrade TypeScript to the latest 5.x (currently 5.9.3) and fix any type errors introduced by stricter checks.

Acceptance criteria

  • TypeScript upgraded to latest 5.x
  • npm run typecheck passes
  • npm ci works without --legacy-peer-deps
  • CI green

Part of the Design System Audit (#6606)

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt issues

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions