Type Alias IfAny<T, TypeIfAny, TypeIfNotAny>

IfAny: IsAny<T> extends true ? TypeIfAny : TypeIfNotAny

An if-else-like type that resolves depending on whether the given type is any.

Type Parameters

  • T
  • TypeIfAny = true
  • TypeIfNotAny = false

IsAny

import type {IfAny} from 'type-fest';

type ShouldBeTrue = IfAny<any>;
//=> true

type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
//=> 'bar'