no-null-type
| null is forbidden in type annotation positions.
Use undefined / optional (?) to represent absence.
What it checks
| null (or null |) appearing in:
- Function parameter type annotations
- Arrow function parameter type annotations
- Variable / property type annotations with an initializer
Why
TypeScript has two ways to represent "no value": null and undefined.
Mixing them creates cognitive overhead at every call site:
undefined is TypeScript's canonical absence value:
Partial<T>usesundefined, notnull- Optional chaining (
?.) and nullish coalescing (??) were designed forundefined JSON.stringifyomitsundefinedvalues but serialisesnull— which is the only placenullis appropriate (see exception below)
Committing to undefined-only simplifies every type in the codebase.
Examples
✗ Incorrect
✓ Correct
Exception — JSON transformation boundary
Immediately after JSON.parse, the data may contain null.
Normalise it to undefined at the boundary before passing it downstream:

