Skip to content

[MEDIUM][DX] Enable TypeScript strict mode across all packages #896

Description

@devJaja

Description

TypeScript strict mode is not enabled across the monorepo packages. This means:

  1. any types are silently allowed, hiding potential runtime errors
  2. Implicit undefined from array/object indexing is not caught
  3. Null checks are not enforced (strictNullChecks disabled)
  4. No noUncheckedIndexedAccess — accessing arr[5] on a 3-element array silently returns undefined
  5. Function parameter bivariance is allowed (strictFunctionTypes disabled)

These unchecked types lead to runtime errors that TypeScript should catch at compile time. The SDK and backend services have complex data flows where strict typing is critical for reliability.

Files to Modify

  • packages/sdk/tsconfig.json — Enable strict mode
  • packages/indexer/tsconfig.json — Enable strict mode
  • packages/dm-relay/tsconfig.json — Enable strict mode
  • packages/analytics-oracle/tsconfig.json — Enable strict mode
  • packages/types/tsconfig.json — Enable strict mode
  • All TypeScript source files — Fix type errors resulting from strict mode

Implementation Guide

  1. Enable strict mode incrementally per package:
    {
      "compilerOptions": {
        "strict": true,
        "noUncheckedIndexedAccess": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "exactOptionalPropertyTypes": true
      }
    }
  2. Start with packages/types (shared types) — fix errors there first
  3. Then packages/sdk — the most critical package
  4. Then backend services: indexer, DM relay, analytics oracle
  5. Common fixes needed:
    • Add null checks for array/object indexing
    • Replace any with proper types
    • Add explicit return types to functions
    • Handle undefined from .find(), .get(), etc.
    • Add type guards for conditional type narrowing

Acceptance Criteria

  • strict: true in all package tsconfig.json files
  • noUncheckedIndexedAccess: true in all packages
  • Zero TypeScript compilation errors with strict mode
  • No any types remain (replace with proper types or unknown)
  • All array/object indexing has null checks
  • pnpm run typecheck passes across all packages
  • pnpm run lint passes
  • No runtime behavior changes (this is a type-only change)
  • PR includes before/after tsc --noEmit output showing zero errors

How to Start Contributing

  1. Fork and branch: git checkout -b chore/typescript-strict-mode
  2. Start with packages/types/tsconfig.json — enable strict, fix errors
  3. Move to each package sequentially
  4. Use pnpm run typecheck to verify each package
  5. Run pnpm run lint across all packages
  6. Open PR with list of type bugs caught and fixed

Difficulty Note

This is a large-scale change that will touch many files. Consider breaking it into multiple PRs:

  • PR 1: Enable strict in packages/types
  • PR 2: Enable strict in packages/sdk
  • PR 3: Enable strict in backend services

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions