prefer-type-fest-entries
Require TypeFest Entries<T> over manual arrays of [keyof T, T[keyof T]] object entry tuple types.
Targeted pattern scopeโ
This rule targets exact mutable arrays of object entry tuples where each tuple is [keyof T, T[keyof T]].
What this rule reportsโ
Array<[keyof T, T[keyof T]]>[keyof T, T[keyof T]][]
The first version intentionally ignores ReadonlyArray<...> until readonly collection semantics are modeled explicitly.
Why this rule existsโ
Entries<T> is the canonical TypeFest helper for the array of entries yielded by object, array, map, and set entry APIs. Using it avoids repeating object-only entry-array aliases and keeps entry-array intent clear.
โ Incorrectโ
type ObjectEntries<T> = Array<[keyof T, T[keyof T]]>;
โ Correctโ
import type { Entries } from "type-fest";
type ObjectEntries<T> = Entries<T>;
Behavior and migration notesโ
- This rule only matches exact object entry tuple arrays.
- It ignores similar tuples when the key target and value target differ.
- It will not autofix when
Entriesis shadowed in the local type scope. - Single entry tuples are handled by
prefer-type-fest-entry.
Additional examplesโ
โ Incorrect โ Additional exampleโ
type ConfigEntries<Config> = [keyof Config, Config[keyof Config]][];
โ Correct โ Additional exampleโ
import type { Entries } from "type-fest";
type ConfigEntries<Config> = Entries<Config>;
โ Correct โ Non-targeted usageโ
type ReadonlyObjectEntries<T> = ReadonlyArray<[keyof T, T[keyof T]]>;
ESLint flat config exampleโ
import typefest from "eslint-plugin-typefest";
export default [
{
plugins: { typefest },
rules: {
"typefest/prefer-type-fest-entries": "error",
},
},
];
When not to use itโ
Disable this rule if your project intentionally keeps object-only entry array aliases that should not use TypeFest collection-aware Entries<T> semantics.
Package documentationโ
TypeFest package documentation:
Source file: source/entries.d.ts
type ObjectEntries<BaseType> = Array<_ObjectEntry<BaseType>>;
export type Entries<BaseType> =
BaseType extends Map<unknown, unknown> ? MapEntries<BaseType>
: BaseType extends Set<unknown> ? SetEntries<BaseType>
: BaseType extends readonly unknown[] ? ArrayEntries<BaseType>
: BaseType extends object ? ObjectEntries<BaseType>
: never;
Rule catalog ID: R108