type-fest 4.18.0 → 4.18.2
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/index.d.ts
CHANGED
|
@@ -123,6 +123,10 @@ export type {ArraySplice} from './source/array-splice';
|
|
|
123
123
|
export type {SetFieldType} from './source/set-field-type';
|
|
124
124
|
export type {Paths} from './source/paths';
|
|
125
125
|
export type {SharedUnionFieldsDeep} from './source/shared-union-fields-deep';
|
|
126
|
+
export type {IsNull} from './source/is-null';
|
|
127
|
+
export type {IfNull} from './source/if-null';
|
|
128
|
+
export type {And} from './source/and';
|
|
129
|
+
export type {Or} from './source/or';
|
|
126
130
|
|
|
127
131
|
// Template literal types
|
|
128
132
|
export type {CamelCase} from './source/camel-case';
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {CamelCase, CamelCaseOptions} from './camel-case';
|
|
2
|
+
import type {UnknownArray} from './unknown-array';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
Convert object properties to camel case recursively.
|
|
@@ -44,11 +45,43 @@ const result: CamelCasedPropertiesDeep<UserWithFriends> = {
|
|
|
44
45
|
@category Template literal
|
|
45
46
|
@category Object
|
|
46
47
|
*/
|
|
47
|
-
export type CamelCasedPropertiesDeep<
|
|
48
|
+
export type CamelCasedPropertiesDeep<
|
|
49
|
+
Value,
|
|
50
|
+
Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true},
|
|
51
|
+
> = Value extends Function
|
|
48
52
|
? Value
|
|
49
|
-
: Value extends
|
|
50
|
-
?
|
|
53
|
+
: Value extends UnknownArray
|
|
54
|
+
? CamelCasedPropertiesArrayDeep<Value>
|
|
51
55
|
: Value extends Set<infer U>
|
|
52
|
-
? Set<CamelCasedPropertiesDeep<U, Options>>
|
|
53
|
-
|
|
56
|
+
? Set<CamelCasedPropertiesDeep<U, Options>>
|
|
57
|
+
: {
|
|
58
|
+
[K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<
|
|
59
|
+
Value[K],
|
|
60
|
+
Options
|
|
61
|
+
>;
|
|
54
62
|
};
|
|
63
|
+
|
|
64
|
+
// This is a copy of DelimiterCasedPropertiesArrayDeep (see: delimiter-cased-properties-deep.d.ts).
|
|
65
|
+
// These types should be kept in sync.
|
|
66
|
+
type CamelCasedPropertiesArrayDeep<Value extends UnknownArray> =
|
|
67
|
+
Value extends []
|
|
68
|
+
? []
|
|
69
|
+
: // Tailing spread array
|
|
70
|
+
Value extends [infer U, ...infer V]
|
|
71
|
+
? [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]
|
|
72
|
+
: Value extends readonly [infer U, ...infer V]
|
|
73
|
+
? readonly [CamelCasedPropertiesDeep<U>, ...CamelCasedPropertiesDeep<V>]
|
|
74
|
+
: // Leading spread array
|
|
75
|
+
Value extends readonly [...infer U, infer V]
|
|
76
|
+
? [...CamelCasedPropertiesDeep<U>, CamelCasedPropertiesDeep<V>]
|
|
77
|
+
: Value extends readonly [...infer U, infer V]
|
|
78
|
+
? readonly [
|
|
79
|
+
...CamelCasedPropertiesDeep<U>,
|
|
80
|
+
CamelCasedPropertiesDeep<V>,
|
|
81
|
+
]
|
|
82
|
+
: // Array
|
|
83
|
+
Value extends Array<infer U>
|
|
84
|
+
? Array<CamelCasedPropertiesDeep<U>>
|
|
85
|
+
: Value extends ReadonlyArray<infer U>
|
|
86
|
+
? ReadonlyArray<CamelCasedPropertiesDeep<U>>
|
|
87
|
+
: never;
|
|
@@ -61,6 +61,8 @@ export type DelimiterCasedPropertiesDeep<
|
|
|
61
61
|
>]: DelimiterCasedPropertiesDeep<Value[K], Delimiter>;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
// This is a copy of CamelCasedPropertiesArrayDeep (see: camel-cased-properties-deep.d.ts).
|
|
65
|
+
// These types should be kept in sync.
|
|
64
66
|
type DelimiterCasedPropertiesArrayDeep<Value extends UnknownArray, Delimiter extends string> =
|
|
65
67
|
Value extends []
|
|
66
68
|
? []
|