Strict null checks active
Why it matters
With strictNullChecks disabled, null and undefined are subtypes of every type — string implicitly includes null. This means the compiler cannot warn when you call .trim() on a value that could be null, or access .user.name on a possibly-undefined response. ISO 25010:2011 §6.5.4 classifies null-safety gaps as reliability defects. Null pointer exceptions are one of the most common runtime crashes in production JavaScript: nearly always preventable, never fun to debug from a Sentry alert.
Severity rationale
High because disabling strictNullChecks allows null and undefined to flow into any typed value silently, making null-dereference crashes invisible to the compiler until they hit production.
Remediation
Enable strictNullChecks via strict: true in tsconfig.json. During migration, the compiler will surface every place where null or undefined could flow into a non-nullable type — fix each with optional chaining, null guards, or explicit non-null assertions with a comment.
// Errors with strictNullChecks: user might be null
const name = user.name;
// Fixed: optional chaining
const name = user?.name ?? 'Anonymous';
// Fixed: explicit guard
if (user === null) throw new Error('User not authenticated');
const name = user.name;
Detection
-
ID:
strict-null-checks -
Severity:
high -
What to look for: In
tsconfig.json, verifystrictNullChecksistrue. Ifstrict: trueis set,strictNullChecksis enabled unless explicitly overridden. Check for"strictNullChecks": falsein the compilerOptions. Without this flag,nullandundefinedare subtypes of every type — meaningstringimplicitly includesnullandundefined, making null pointer exceptions invisible to TypeScript until runtime. Scan a sample of the codebase for patterns that would error under strict null checks: calling methods on values that may be null, accessing properties on possibly-undefined objects without optional chaining. -
Detector snippet (shell-capable tools only): If
jqis available, read the explicitcompilerOptions.strictNullChecksvalue. Output"true"or"null"means pass IFstrict: trueis set elsewhere. Output"false"fails regardless. Exit >=2 (file not found) — fall back to prose reasoning.jq -r '.compilerOptions.strictNullChecks // "null"' tsconfig.json -
Pass criteria: Count all tsconfig files.
strictNullChecksistrue(directly or viastrict: true) and not explicitly overridden withfalsewith at least 1 verified location. -
Fail criteria: Explicitly
false, orstrictis absent/false andstrictNullChecksis not individually enabled. -
Skip (N/A) when: Project has no TypeScript files.
-
Detail on fail:
"strictNullChecks is disabled; null and undefined are assignable to all types, masking null dereference bugs" -
Remediation: Enable
strictNullChecks(or usestrict: true). When migrating an existing codebase, you'll surface errors where values may be null — address each with optional chaining or explicit null guards:// Errors with strictNullChecks: user might be null const name = user.name; // Fixed: optional chaining const name = user?.name ?? 'Anonymous'; // Fixed: explicit guard if (user === null) throw new Error('User not authenticated'); const name = user.name;
External references
- iso-25010:2011 · maintainability.modifiability — Maintainability — Modifiability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from code-quality-essentials·automated
- 2026-04-20·v1.1.0·Add Phase 6.0 detect-jq snippet for deterministic tsconfig.strictNullChecks parse·by cakleinman