TypeScript Type Guards
Surfaces union-type usage and the presence (or absence) of type predicates and discriminated-union patterns.
Union types are most useful when narrowed cleanly. Type predicates (x is T), discriminated unions (type: 'a' | 'b'), and exhaustiveness checks turn unions from runtime ambiguity into compile-time safety. This analysis surfaces unions that lack narrowing infrastructure so type-safety improvements can be targeted.
Severity guide
- info
- A positive narrowing pattern is in use, or unions are present but the absence of narrowing isn't critical.
- warning
- Union types lack exhaustive narrowing — type-safety holes are possible.
- critical
- Not currently emitted by this analysis.
Remediation
Add type predicates for runtime narrowing; convert union types to discriminated unions where appropriate; add exhaustiveness assertions.
Add type predicates for runtime narrowing; convert union types to discriminated unions where appropriate; add exhaustiveness assertions.