-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutable.ts
44 lines (33 loc) · 974 Bytes
/
mutable.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
36
37
38
39
40
41
42
43
44
/*
* Types representing valid JSON values.
*/
export type JsonPrimitive = string | number | boolean | null;
export type JsonObject = {
[key: string]: JsonValue|undefined,
[key: symbol]: never|undefined,
};
export type JsonArray = JsonValue[];
export type JsonStructure = JsonArray | JsonObject;
export type JsonValue = JsonPrimitive | JsonStructure;
/*
* Types that can be converted to JSON.
*/
export type JsonCompatibleObject = {
[key: string]: JsonCompatible|undefined,
[key: symbol]: never|undefined,
};
export type JsonCompatibleArray = JsonCompatible[];
export type JsonCompatibleStructure = JsonCompatibleArray | JsonCompatibleObject;
/**
* A class that can be serialized to JSON.
*/
export type JsonConvertible = {
toJSON(): JsonCompatible,
};
/**
* Any value that can be safely serialized to JSON using `JSON.stringify()`.
*/
export type JsonCompatible =
JsonPrimitive
| JsonConvertible
| JsonCompatibleStructure;