forked from sindresorhus/type-fest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
is-if-never.d.ts
35 lines (26 loc) · 902 Bytes
/
is-if-never.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
Returns a boolean for whether the given type is `never`.
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
@link https://stackoverflow.com/a/53984913/10292952
@example
```
import type {IsNever} from 'type-fest';
```
@category Utilities
*/
export type IsNever<T> = [T] extends [never] ? true : false;
/**
If the given type `T` is `never`, the returned type is `TypeIfNever`. Otherwise,
the return type is `TypeIfNotNever`. If only `T` is specified, `TypeIfNever`
will be `true` and `TypeIfNotNever` will be false.
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
@link https://stackoverflow.com/a/53984913/10292952
@example
```
import type {IfNever} from 'type-fest';
```
@category Utilities
*/
export type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
);