UNPKG

468 BTypeScriptView Raw
1import type {IsAny} from './is-any';
2
3/**
4An if-else-like type that resolves depending on whether the given type is `any`.
5
6@see {@link IsAny}
7
8@example
9```
10import type {IfAny} from 'type-fest';
11
12type ShouldBeTrue = IfAny<any>;
13//=> true
14
15type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
16//=> 'bar'
17```
18
19@category Type Guard
20@category Utilities
21*/
22export type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
23 IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
24);