ASAASA Standard
Active Phase 1Production Foundation

TypeScript Strict Mode

Foundation · CFG-01 · Priority: P1

Why It Matters

Without strict: true in tsconfig.json, TypeScript allows implicit any types, unchecked null access, and loose type assertions. AI tools exploit this permissiveness extensively — they generate code that compiles but crashes at runtime.

Strict mode forces the AI tool to produce correctly typed code. Without it, type errors silently pass compilation and surface as runtime crashes in production.

Priority: P1 — TypeScript strict mode is the cheapest safety net against AI-generated type errors.

Affected Stack: Any TypeScript project


The Problem

// ❌ tsconfig.json — strict mode disabled (default)
{
  "compilerOptions": {
    "strict": false
    // or simply missing — defaults to false
  }
}

This allows:

  • function process(data) {}data is implicitly any
  • user.profile.name — crashes if profile is null
  • const price = data as number — no runtime check

The Fix

// ✅ tsconfig.json — strict mode enabled
{
  "compilerOptions": {
    "strict": true
  }
}

This enables:

  • noImplicitAny — all variables must have explicit types
  • strictNullChecks — null/undefined must be handled explicitly
  • strictFunctionTypes — function parameter types are checked properly
  • And 4 more strict sub-flags

If enabling strict on an existing project

Enabling strict on a large AI-generated codebase will surface many errors. Address them incrementally:

  1. Enable strict: true
  2. Fix errors module by module (start with critical paths: auth, billing)
  3. Use // @ts-expect-error sparingly for known-safe patterns you'll fix later

References


Related Checks


Is your app safe? Run Free Scan →