Skip to main content

prefer-type-fest-is-mutually-assignable

Prefer IsMutuallyAssignable from type-fest 6 for the following pattern.

Targeted pattern scopeโ€‹

Nested, non-distributive checks that compare the same two named types in both directions.

What this rule reportsโ€‹

type Compatible<A, B> = [A] extends [B] ? [B] extends [A] ? true : false : false;

Why this rule existsโ€‹

A one-way assignability check has a different result for subtypes. Removing the tuple wrappers also distributes over unions.

โŒ Incorrectโ€‹

type Compatible<A, B> = [A] extends [B] ? [B] extends [A] ? true : false : false;

โœ… Correctโ€‹

import type { IsMutuallyAssignable } from "type-fest";

type Compatible<A, B> = IsMutuallyAssignable<A, B>;

Behavior and migration notesโ€‹

The rule runs when the linted file resolves type-fest major version 6. It preserves the outer alias and its parameters. The fixer leaves comments in place and uses the configured import policy.

Package documentationโ€‹

TypeFest package documentation:

Rule catalog ID: R138

Further readingโ€‹