-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy pathis-unknown.d.ts
More file actions
43 lines (31 loc) · 782 Bytes
/
is-unknown.d.ts
File metadata and controls
43 lines (31 loc) · 782 Bytes
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
36
37
38
39
40
41
42
43
import type {IsNull} from './is-null.d.ts';
/**
Returns a boolean for whether the given type is `unknown`.
@link https://github.com/dsherret/conditional-type-checks/pull/16
Useful in type utilities, such as when dealing with unknown data from API calls.
@example
```
import type {IsUnknown} from 'type-fest';
type A = IsUnknown<unknown>;
//=> true
type B = IsUnknown<any>;
//=> false
type C = IsUnknown<never>;
//=> false
type D = IsUnknown<unknown[]>;
//=> false
type E = IsUnknown<object>;
//=> false
type F = IsUnknown<string>;
//=> false
```
@category Utilities
*/
export type IsUnknown<T> = (
unknown extends T // `T` can be `unknown` or `any`
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
? true
: false
: false
);
export {};