Skip to main content

prefer-type-fest-is-any

Require TypeFest IsAny<T> over manual 0 extends 1 & T conditional type guards.

Targeted pattern scopeโ€‹

This rule reports exact conditional type guards shaped like 0 extends 1 & T ? true : false.

The rule also recognizes the TypeScript built-in NoInfer<T> wrapper used by TypeFest's own implementation.

What this rule reportsโ€‹

This rule reports manual any detection helpers that can be replaced by IsAny<T>.

  • 0 extends 1 & T ? true : false
  • 0 extends 1 & NoInfer<T> ? true : false

Why this rule existsโ€‹

IsAny<T> documents the intent directly and avoids repeating a non-obvious conditional type trick across a codebase.

โŒ Incorrectโ€‹

type Result<T> = 0 extends 1 & T ? true : false;

โœ… Correctโ€‹

type Result<T> = IsAny<T>;

Behavior and migration notesโ€‹

  • The rule intentionally requires the exact 0 extends 1 & T ? true : false shape.
  • Reversed branches and non-zero check literals are ignored.
  • Autofix is skipped when IsAny is shadowed in the local scope.

Additional examplesโ€‹

โŒ Incorrect โ€” With NoInferโ€‹

type Result<T> = 0 extends 1 & NoInfer<T> ? true : false;

โœ… Correct โ€” With NoInferโ€‹

type Result<T> = IsAny<T>;

โœ… Correct โ€” Existing utilityโ€‹

type Result<T> = IsAny<T>;

ESLint flat config exampleโ€‹

import typefest from "eslint-plugin-typefest";

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

When not to use itโ€‹

Disable this rule if a public type alias must preserve a hand-written conditional for compatibility documentation.

Package documentationโ€‹

TypeFest package documentation:

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

Rule catalog ID: R103

Further readingโ€‹

Adoption resourcesโ€‹