mirror of
https://github.com/sindresorhus/type-fest.git
synced 2025-12-08 19:25:05 +00:00
25 lines
468 B
TypeScript
25 lines
468 B
TypeScript
import type {IsAny} from './is-any';
|
|
|
|
/**
|
|
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
|
|
@see {@link IsAny}
|
|
|
|
@example
|
|
```
|
|
import type {IfAny} from 'type-fest';
|
|
|
|
type ShouldBeTrue = IfAny<any>;
|
|
//=> true
|
|
|
|
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
//=> 'bar'
|
|
```
|
|
|
|
@category Type Guard
|
|
@category Utilities
|
|
*/
|
|
export type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
|
|
IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
|
|
);
|