prefer-type-fest-entry
Require TypeFest Entry<T> over manual [keyof T, T[keyof T]] object entry tuple types.
Targeted pattern scopeโ
This rule targets exact object entry tuple aliases where the first tuple element is keyof T and the second element is T[keyof T] for the same target type.
What this rule reportsโ
[keyof T, T[keyof T]]
The rule intentionally does not report array wrappers. Use prefer-type-fest-entries for arrays of entry tuples.
Why this rule existsโ
Entry<T> is the canonical TypeFest helper for a single entry yielded by object, array, map, and set entry APIs. Using it avoids repeated object-only tuple aliases and keeps entry intent visible.
โ Incorrectโ
type ObjectEntry<T> = [keyof T, T[keyof T]];
โ Correctโ
import type { Entry } from "type-fest";
type ObjectEntry<T> = Entry<T>;
Behavior and migration notesโ
- This rule only matches exact object entry tuple syntax.
- It ignores similar tuples when the key target and value target differ.
- It will not autofix when
Entryis shadowed in the local type scope. Array<[keyof T, T[keyof T]]>and[keyof T, T[keyof T]][]are handled byprefer-type-fest-entries.
Additional examplesโ
โ Incorrect โ Additional exampleโ
type ConfigEntry<Config> = [keyof Config, Config[keyof Config]];
โ Correct โ Additional exampleโ
import type { Entry } from "type-fest";
type ConfigEntry<Config> = Entry<Config>;
โ Correct โ Non-targeted usageโ
type Pair<T, U> = [keyof T, U[keyof T]];
ESLint flat config exampleโ
import typefest from "eslint-plugin-typefest";
export default [
{
plugins: { typefest },
rules: {
"typefest/prefer-type-fest-entry": "error",
},
},
];
When not to use itโ
Disable this rule if your project intentionally keeps object-only entry tuple aliases that should not use TypeFest collection-aware Entry<T> semantics.
Package documentationโ
TypeFest package documentation:
Source file: source/entry.d.ts
export type _ObjectEntry<BaseType> = [keyof BaseType, BaseType[keyof BaseType]];
export type Entry<BaseType> =
BaseType extends Map<unknown, unknown> ? _MapEntry<BaseType>
: BaseType extends Set<unknown> ? _SetEntry<BaseType>
: BaseType extends readonly unknown[] ? _ArrayEntry<BaseType>
: BaseType extends object ? _ObjectEntry<BaseType>
: never;
Rule catalog ID: R107