prefer-type-fest-is-undefined
Require TypeFest IsUndefined<T> over manual tuple-wrapped undefined conditional type guards.
Targeted pattern scopeโ
This rule reports exact conditional type guards shaped like [T] extends [undefined] ? true : false.
It does not report distributive T extends undefined ? true : false checks.
What this rule reportsโ
This rule reports manual non-distributive undefined checks that can be replaced by IsUndefined<T>.
[T] extends [undefined] ? true : false
Why this rule existsโ
IsUndefined<T> makes undefined detection intent explicit and keeps type-guard helpers aligned with TypeFest.
โ Incorrectโ
type Result<T> = [T] extends [undefined] ? true : false;
โ Correctโ
type Result<T> = IsUndefined<T>;
Behavior and migration notesโ
- Only the canonical tuple-wrapped form is reported.
nullandneverguards are handled by their own rules.- Autofix is skipped when
IsUndefinedis shadowed in the local scope.
Additional examplesโ
โ Incorrect โ Generic helperโ
type Missing<T> = [T] extends [undefined] ? true : false;
โ Correct โ Generic helperโ
type Missing<T> = IsUndefined<T>;
โ Correct โ Distributive conditionalโ
type Missing<T> = T extends undefined ? true : false;
ESLint flat config exampleโ
import typefest from "eslint-plugin-typefest";
export default [
{
plugins: { typefest },
rules: {
"typefest/prefer-type-fest-is-undefined": "error",
},
},
];
When not to use itโ
Disable this rule if a public helper must keep a hand-written undefined conditional for teaching or compatibility reasons.
Package documentationโ
TypeFest package documentation:
Source file: source/is-undefined.d.ts
Rule catalog ID: R106