Pattern: Use of null
literal
Issue: -
Using undefined
instead of null
simplifies input validation and makes TypeScript types less verbose. Most developers use null
and undefined
interchangeably, so standardizing on undefined
improves consistency.
Example of incorrect code:
let foo = null;
function bar(baz = null) {}
Example of correct code:
let foo;
function bar(baz) {}