Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 461 Bytes

no-null.md

File metadata and controls

21 lines (15 loc) · 461 Bytes

Pattern: Use of null literal

Issue: -

Description

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.

Examples

Example of incorrect code:

let foo = null;
function bar(baz = null) {}

Example of correct code:

let foo;
function bar(baz) {}