Type Alias IfUnknown<T, TypeIfUnknown, TypeIfNotUnknown>

IfUnknown: IsUnknown<T> extends true ? TypeIfUnknown : TypeIfNotUnknown

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

Type Parameters

  • T
  • TypeIfUnknown = true
  • TypeIfNotUnknown = false
import type {IfUnknown} from 'type-fest';

type ShouldBeTrue = IfUnknown<unknown>;
//=> true

type ShouldBeBar = IfUnknown<'not unknown', 'foo', 'bar'>;
//=> 'bar'