Skip to main content

prefer-type-fest-falsy

Prefer Falsy from type-fest 6 for the following pattern.

Targeted pattern scopeโ€‹

A union containing each of the six falsy literal types exactly once, in any order.

What this rule reportsโ€‹

type Local = false | null | 0n | undefined | '' | 0;

Why this rule existsโ€‹

The bigint zero is distinct from the numeric zero. A union that omits either one describes a different set of values.

โŒ Incorrectโ€‹

type Local = false | null | 0n | undefined | '' | 0;

โœ… Correctโ€‹

import type { Falsy } from "type-fest";

type Local = Falsy;

Behavior and migration notesโ€‹

The rule runs when the linted file resolves type-fest major version 6. It preserves the outer alias and its parameters. The fixer leaves comments in place and uses the configured import policy.

Package documentationโ€‹

TypeFest package documentation:

Rule catalog ID: R137

Further readingโ€‹