prefer-type-fest-truthy
Prefer Truthy from type-fest 6 for the following pattern.
Targeted pattern scopeโ
The built-in NonNullable and Exclude around the union of void and the upstream Falsy type.
What this rule reportsโ
type Clean<T> = NonNullable<Exclude<T, Falsy | void>>;
Why this rule existsโ
Truthy excludes void as well as the falsy literals. An ordinary non-nullable type still includes false, zero, and the empty string.
โ Incorrectโ
import type { Falsy } from "type-fest";
type Clean<T> = NonNullable<Exclude<T, Falsy | void>>;
โ Correctโ
import type { Truthy } from "type-fest";
type Clean<T> = Truthy<T>;
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: R144