zcb 0.3.2 → 0.3.3
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/dist/production.analysis.txt +19 -19
- package/dist/types/cjs/types.d.cts +4 -3
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/types.d.ts +4 -3
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/createConfigReader.test.ts +1 -0
- package/src/types.ts +15 -10
package/package.json
CHANGED
|
@@ -56,6 +56,7 @@ describe('createConfigReader', () => {
|
|
|
56
56
|
it('should throw the expected error', () => {
|
|
57
57
|
const reader = createReader();
|
|
58
58
|
|
|
59
|
+
// @ts-expect-error Required to test error
|
|
59
60
|
expect(() => reader.read('pages.contactDetails.sections')).toThrow(
|
|
60
61
|
'Path resolved to an object or an array of objects, but `read` can only resolve to a primitive value or an array of primitives. Use the `scope` method instead',
|
|
61
62
|
);
|
package/src/types.ts
CHANGED
|
@@ -55,16 +55,11 @@ export type Primitive = string | number | boolean | bigint | symbol | null | und
|
|
|
55
55
|
|
|
56
56
|
export type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...0[]];
|
|
57
57
|
|
|
58
|
-
export type
|
|
59
|
-
? never
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
T extends readonly any[]
|
|
64
|
-
? LeafPath
|
|
65
|
-
: {
|
|
66
|
-
[K in keyof T & string]: Leaves<T[K], [...LeafPath, K], Prev[Depth]>;
|
|
67
|
-
}[keyof T & string];
|
|
58
|
+
export type IsArrayOfPrimitives<T> = T extends readonly (infer U)[]
|
|
59
|
+
? Exclude<U, Primitive> extends never
|
|
60
|
+
? true
|
|
61
|
+
: false
|
|
62
|
+
: false;
|
|
68
63
|
|
|
69
64
|
export type OwnKeys<T> = Exclude<
|
|
70
65
|
{
|
|
@@ -74,6 +69,16 @@ export type OwnKeys<T> = Exclude<
|
|
|
74
69
|
`${string}[Symbol.${string}`
|
|
75
70
|
>;
|
|
76
71
|
|
|
72
|
+
export type Leaves<T, LeafPath extends string[] = [], Depth extends number = 10> = Depth extends never
|
|
73
|
+
? never
|
|
74
|
+
: T extends Primitive
|
|
75
|
+
? LeafPath
|
|
76
|
+
: IsArrayOfPrimitives<T> extends true
|
|
77
|
+
? LeafPath
|
|
78
|
+
: {
|
|
79
|
+
[K in OwnKeys<T>]: Leaves<T[K], [...LeafPath, K], Prev[Depth]>;
|
|
80
|
+
}[OwnKeys<T>];
|
|
81
|
+
|
|
77
82
|
export type Paths<T, ScopePath extends string[] = [], Depth extends number = 10> = Depth extends never
|
|
78
83
|
? never
|
|
79
84
|
: T extends Primitive
|