@tolki/types 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/enums.d.ts +17 -12
package/package.json
CHANGED
package/src/enums.d.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extract the case key names from the _cases tuple.
|
|
3
|
+
* Returns `never` when `_cases` is not declared on the concrete type.
|
|
3
4
|
*/
|
|
4
|
-
export type CaseKeys<TEnum extends EnumConst> =
|
|
5
|
-
TEnum["_cases"]
|
|
6
|
-
|
|
5
|
+
export type CaseKeys<TEnum extends EnumConst> = "_cases" extends keyof TEnum
|
|
6
|
+
? NonNullable<TEnum["_cases"]>[number]
|
|
7
|
+
: never;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Extracts the instance method key names from the `_methods` tuple.
|
|
11
|
+
* Returns `never` when `_methods` is not declared on the concrete type.
|
|
10
12
|
*/
|
|
11
|
-
export type MethodKeys<TEnum extends EnumConst> =
|
|
12
|
-
TEnum["_methods"]
|
|
13
|
-
|
|
13
|
+
export type MethodKeys<TEnum extends EnumConst> = "_methods" extends keyof TEnum
|
|
14
|
+
? NonNullable<TEnum["_methods"]>[number]
|
|
15
|
+
: never;
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Extracts the static helper key names from the `_static` tuple.
|
|
19
|
+
* Returns `never` when `_static` is not declared on the concrete type.
|
|
17
20
|
*/
|
|
18
|
-
export type StaticKeys<TEnum extends EnumConst> =
|
|
19
|
-
TEnum["_static"]
|
|
20
|
-
|
|
21
|
+
export type StaticKeys<TEnum extends EnumConst> = "_static" extends keyof TEnum
|
|
22
|
+
? NonNullable<TEnum["_static"]>[number]
|
|
23
|
+
: never;
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Extracts the helper key names from the `_helpers` tuple.
|
|
27
|
+
* Returns `never` when `_helpers` is not declared on the concrete type.
|
|
24
28
|
*/
|
|
25
|
-
export type HelperKeys<TEnum extends EnumConst> =
|
|
26
|
-
TEnum["_helpers"]
|
|
27
|
-
|
|
29
|
+
export type HelperKeys<TEnum extends EnumConst> = "_helpers" extends keyof TEnum
|
|
30
|
+
? NonNullable<TEnum["_helpers"]>[number]
|
|
31
|
+
: never;
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* Constraint for all generated enum const objects.
|
|
@@ -38,6 +42,7 @@ export type HelperKeys<TEnum extends EnumConst> = NonNullable<
|
|
|
38
42
|
*/
|
|
39
43
|
export type EnumConst = {
|
|
40
44
|
readonly _cases?: readonly string[];
|
|
45
|
+
readonly _helpers?: readonly string[];
|
|
41
46
|
readonly _methods?: readonly string[];
|
|
42
47
|
readonly _static?: readonly string[];
|
|
43
48
|
readonly [key: string]: unknown;
|