Skip to main content

prefer-type-fest-distributed-omit

Prefer DistributedOmit from type-fest over distributive conditional helpers built from Omit.

This rule lives only in the experimental preset and reports without autofixing.

Targeted pattern scopeโ€‹

This rule focuses on the common helper shape that distributes Omit over a union manually:

  • Union extends unknown ? Omit<Union, Key> : never
  • Union extends any ? Omit<Union, Key> : never

It intentionally ignores ordinary non-distributive Omit usage and unrelated conditional helpers.

What this rule reportsโ€‹

This rule reports conditional helpers when all of the following are true:

  • the false branch is never
  • the conditional distributes over the checked type with extends unknown or extends any
  • the true branch is exactly Omit<CheckedType, KeyType>

The rule is currently report-only. It does not autofix or suggest a replacement yet.

Why this rule existsโ€‹

DistributedOmit<ObjectType, KeyType> makes the union-preserving behavior explicit.

  • Readers do not need to mentally simulate the distributive conditional.
  • The Type-Fest helper explains why this is different from plain Omit.
  • Consistent adoption reduces duplicate one-off helpers across a codebase.

โŒ Incorrectโ€‹

type WithoutKeys<Union, Key extends PropertyKey> =
Union extends unknown ? Omit<Union, Key> : never;

โœ… Correctโ€‹

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

type WithoutKeys<Union, Key extends PropertyKey> =
DistributedOmit<Union, Key>;

Behavior and migration notesโ€‹

  • This rule only reports the narrow distributive-Omit helper pattern.
  • It does not report ordinary Omit<T, K> usage.
  • It does not try to prove that your generic key constraints match Type-Fest exactly; it only reports the direct structural helper pattern.

ESLint flat config exampleโ€‹

import typefest from "eslint-plugin-typefest";

export default [typefest.configs.experimental];

When not to use itโ€‹

Disable this rule if your team prefers to keep a local distributive helper name or if you intentionally avoid Type-Fest for these object-union utilities.

Package documentationโ€‹

TypeFest package documentation:

Source file: source/distributed-omit.d.ts

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

type Result<Union, Key extends PropertyKey> = DistributedOmit<Union, Key>;

Rule catalog ID: R090

Further readingโ€‹

Adoption resourcesโ€‹