Skip to main content

prefer-type-fest-is-never

Require TypeFest IsNever<T> over manual tuple-wrapped never conditional type guards.

Targeted pattern scopeโ€‹

This rule reports exact conditional type guards shaped like [T] extends [never] ? true : false.

It does not report distributive T extends never ? true : false checks because those behave differently when T is never.

What this rule reportsโ€‹

This rule reports manual non-distributive never checks that can be replaced by IsNever<T>.

  • [T] extends [never] ? true : false

Why this rule existsโ€‹

IsNever<T> makes the non-distributive guard intent explicit and avoids repeated tuple-wrapping boilerplate.

โŒ Incorrectโ€‹

type Result<T> = [T] extends [never] ? true : false;

โœ… Correctโ€‹

type Result<T> = IsNever<T>;

Behavior and migration notesโ€‹

  • Only the canonical tuple-wrapped form is reported.
  • Reversed boolean branches are ignored.
  • Autofix is skipped when IsNever is shadowed in the local scope.

Additional examplesโ€‹

โŒ Incorrect โ€” Generic helperโ€‹

type Missing<T> = [T] extends [never] ? true : false;

โœ… Correct โ€” Generic helperโ€‹

type Missing<T> = IsNever<T>;

โœ… Correct โ€” Distributive conditionalโ€‹

type Missing<T> = T extends never ? true : false;

ESLint flat config exampleโ€‹

import typefest from "eslint-plugin-typefest";

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

When not to use itโ€‹

Disable this rule if a published helper intentionally mirrors TypeScript conditional type mechanics in its source.

Package documentationโ€‹

TypeFest package documentation:

Source file: source/is-never.d.ts

Rule catalog ID: R104

Further readingโ€‹

Adoption resourcesโ€‹