-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.d.ts
48 lines (43 loc) · 1.46 KB
/
basic.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
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
*
* @category Class
*/
export type Class<T, Arguments extends unknown[] = any[]> =
& Constructor<T, Arguments>
& { prototype: T };
/**
* Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
* @category Class
*/
export type Constructor<T, Arguments extends unknown[] = any[]> = new (
...arguments_: Arguments
) => T;
/**
* Matches a JSON object.
*
* This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
*
* @category JSON
*/
export type JsonObject =
& { [Key in string]: JsonValue }
& { [Key in string]?: JsonValue | undefined };
/**
* Matches a JSON array.
*
* @category JSON
*/
export type JsonArray = JsonValue[];
/**
* Matches any valid JSON primitive value.
*
* @category JSON
*/
export type JsonPrimitive = string | number | boolean | null;
/**
* Matches any valid JSON value.
* @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
* @category JSON
*/
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;