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) {}—datais implicitlyanyuser.profile.name— crashes ifprofileis nullconst 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 typesstrictNullChecks— null/undefined must be handled explicitlystrictFunctionTypes— 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:
- Enable
strict: true - Fix errors module by module (start with critical paths: auth, billing)
- Use
// @ts-expect-errorsparingly for known-safe patterns you'll fix later
References
Related Checks
- Global Error Boundary — ERR-01
Is your app safe? Run Free Scan →