Skip to main content

prefer-type-fest-and-all

Require TypeFest AndAll<TTuple> over AllExtend<TTuple, true> boolean-tuple checks.

Targeted pattern scopeโ€‹

This rule targets direct and namespace-qualified references to AllExtend<TTuple, true> imported from type-fest.

What this rule reportsโ€‹

  • AllExtend<TTuple, true> when it is being used as a boolean-tuple conjunction check.

Why this rule existsโ€‹

AndAll is the dedicated TypeFest helper for checking whether all boolean tuple members are true. It is shorter, more intention-revealing, and matches the new canonical TypeFest naming.

โŒ Incorrectโ€‹

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

type AllFlagsTrue = AllExtend<[true, true, false], true>;

โœ… Correctโ€‹

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

type AllFlagsTrue = AndAll<[true, true, false]>;

Behavior and migration notesโ€‹

  • This rule only targets AllExtend<TTuple, true>.
  • It does not report AllExtend<TTuple, SomeOtherType> usages.
  • Namespace-qualified type-fest references are reported too.

Additional examplesโ€‹

โŒ Incorrect โ€” Additional exampleโ€‹

import type * as TypeFest from "type-fest";

type Ready = TypeFest.AllExtend<[true, true, true], true>;

โœ… Correct โ€” Additional exampleโ€‹

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

type Ready = AndAll<[true, true, true]>;

โœ… Correct โ€” Non-targeted usageโ€‹

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

type AllNumbers = AllExtend<[1, 2, 3], number>;

ESLint flat config exampleโ€‹

import typefest from "eslint-plugin-typefest";

export default [
{
plugins: { typefest },
rules: {
"typefest/prefer-type-fest-and-all": "error",
},
},
];

When not to use itโ€‹

Disable this rule if your codebase intentionally prefers the more general AllExtend<TTuple, true> spelling for boolean tuple checks.

Package documentationโ€‹

TypeFest package documentation:

Source file: source/and-all.d.ts

/**
Returns a boolean for whether all of the given elements are `true`.

Use-cases:
- Check if all conditions in a list of booleans are met.
*/
export type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;

Rule catalog ID: R077

Further readingโ€‹

Adoption resourcesโ€‹