UNPKG

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