-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
69 lines (62 loc) · 1.61 KB
/
types.ts
File metadata and controls
69 lines (62 loc) · 1.61 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* @file Public type surface for `objects/*` modules — getter definition shapes
* and the `Remap` type helper. Pure types, no runtime side effects.
*/
/**
* Record of property keys mapped to getter functions. Used for defining lazy
* getters on objects.
*/
export type GetterDefObj = { [key: PropertyKey]: () => unknown }
/**
* Statistics tracking for lazy getter initialization. Keeps track of which lazy
* getters have been accessed and initialized.
*/
export type LazyGetterStats = { initialized?: Set<PropertyKey> | undefined }
/**
* Configuration options for creating constants objects.
*/
export type ConstantsObjectOptions = {
/**
* Lazy getter definitions to attach to the object.
*
* @default undefined
*/
getters?: GetterDefObj | undefined
/**
* Internal properties to store under `kInternalsSymbol`.
*
* @default undefined
*/
internals?: object | undefined
/**
* Properties to mix into the object (lower priority than `props`).
*
* @default undefined
*/
mixin?: object | undefined
}
/**
* Type helper that creates a remapped type with fresh property mapping. Useful
* for flattening intersection types into a single object type.
*/
export type Remap<T> = { [K in keyof T]: T[K] } extends infer O
? { [K in keyof O]: O[K] }
: never
/**
* Type for dynamic lazy getter record.
*/
export type LazyGetterRecord<T> = {
[key: PropertyKey]: () => T
}
/**
* Type for generic property bag.
*/
export type PropertyBag = {
[key: PropertyKey]: unknown
}
/**
* Type for generic sorted object entries.
*/
export type SortedObject<T> = {
[key: PropertyKey]: T
}