Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Latest commit

 

History

History
27 lines (16 loc) · 578 Bytes

prefer-maybe.md

File metadata and controls

27 lines (16 loc) · 578 Bytes

Prefer Maybe to T | null or T | undefined (prefer-maybe)

Don't inculde null or undefined in a union. Instad, wrap the type in Maybe.

Rule Details

This rule aims to ensure that we don't treat null and undefined differently.

Autofixer available.

Examples of incorrect code for this rule:

const x: string | null = "hello";

Examples of correct code for this rule:

const x: Maybe<string> = "hello";

When Not To Use It

With third-party software that needs to differentiate between null and undefined.

Further Reading