UNPKG

631 BTypeScriptView Raw
1/**
2Represents an object with `unknown` value. You probably want this instead of `{}`.
3
4Use case: You have an object whose keys and values are unknown to you.
5
6@example
7```
8import type {UnknownRecord} from 'type-fest';
9
10function toJson(object: UnknownRecord) {
11 return JSON.stringify(object);
12}
13
14toJson({hello: 'world'});
15//=> '{"hello":"world"}'
16
17function isObject(value: unknown): value is UnknownRecord {
18 return typeof value === 'object' && value !== null;
19}
20
21isObject({hello: 'world'});
22//=> true
23
24isObject('hello');
25//=> false
26```
27
28@category Type
29@category Object
30*/
31export type UnknownRecord = Record<PropertyKey, unknown>;