type-fest 4.40.0 → 4.40.1
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
CHANGED
|
@@ -68,12 +68,11 @@ type _CamelCasedPropertiesDeep<
|
|
|
68
68
|
? CamelCasedPropertiesArrayDeep<Value, Options>
|
|
69
69
|
: Value extends Set<infer U>
|
|
70
70
|
? Set<_CamelCasedPropertiesDeep<U, Options>>
|
|
71
|
-
:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
71
|
+
: Value extends object
|
|
72
|
+
? {
|
|
73
|
+
[K in keyof Value as CamelCase<K, Options>]: _CamelCasedPropertiesDeep<Value[K], Options>;
|
|
74
|
+
}
|
|
75
|
+
: Value;
|
|
77
76
|
|
|
78
77
|
// This is a copy of DelimiterCasedPropertiesArrayDeep (see: delimiter-cased-properties-deep.d.ts).
|
|
79
78
|
// These types should be kept in sync.
|
|
@@ -72,13 +72,13 @@ type _DelimiterCasedPropertiesDeep<
|
|
|
72
72
|
: Value extends UnknownArray
|
|
73
73
|
? DelimiterCasedPropertiesArrayDeep<Value, Delimiter, Options>
|
|
74
74
|
: Value extends Set<infer U>
|
|
75
|
-
? Set<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
? Set<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
76
|
+
: Value extends object
|
|
77
|
+
? {
|
|
78
|
+
[K in keyof Value as DelimiterCase<K, Delimiter, Options>]:
|
|
79
|
+
_DelimiterCasedPropertiesDeep<Value[K], Delimiter, Options>
|
|
80
|
+
}
|
|
81
|
+
: Value;
|
|
82
82
|
|
|
83
83
|
// This is a copy of CamelCasedPropertiesArrayDeep (see: camel-cased-properties-deep.d.ts).
|
|
84
84
|
// These types should be kept in sync.
|
package/source/partial-deep.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {ApplyDefaultOptions, BuiltIns} from './internal';
|
|
2
|
+
import type {IsNever} from './is-never';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
@see {@link PartialDeep}
|
|
@@ -95,27 +96,29 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
|
95
96
|
export type PartialDeep<T, Options extends PartialDeepOptions = {}> =
|
|
96
97
|
_PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
97
98
|
|
|
98
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((
|
|
99
|
+
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown))
|
|
99
100
|
? T
|
|
100
|
-
: T extends
|
|
101
|
-
?
|
|
102
|
-
: T extends
|
|
103
|
-
?
|
|
104
|
-
: T extends
|
|
105
|
-
?
|
|
106
|
-
: T extends
|
|
107
|
-
?
|
|
108
|
-
: T extends
|
|
109
|
-
?
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
: IsNever<keyof T> extends true // For functions with no properties
|
|
102
|
+
? T
|
|
103
|
+
: T extends Map<infer KeyType, infer ValueType>
|
|
104
|
+
? PartialMapDeep<KeyType, ValueType, Options>
|
|
105
|
+
: T extends Set<infer ItemType>
|
|
106
|
+
? PartialSetDeep<ItemType, Options>
|
|
107
|
+
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
108
|
+
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
109
|
+
: T extends ReadonlySet<infer ItemType>
|
|
110
|
+
? PartialReadonlySetDeep<ItemType, Options>
|
|
111
|
+
: T extends object
|
|
112
|
+
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
113
|
+
? Options['recurseIntoArrays'] extends true
|
|
114
|
+
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
115
|
+
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
116
|
+
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
117
|
+
: Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
118
|
+
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
119
|
+
: T // If they don't opt into array testing, just use the original type
|
|
120
|
+
: PartialObjectDeep<T, Options>
|
|
121
|
+
: unknown;
|
|
119
122
|
|
|
120
123
|
/**
|
|
121
124
|
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
@@ -140,6 +143,9 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
|
|
|
140
143
|
/**
|
|
141
144
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
142
145
|
*/
|
|
143
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
147
|
+
(ObjectType extends (...arguments_: any) => unknown
|
|
148
|
+
? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
|
|
149
|
+
: {}) & ({
|
|
150
|
+
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
|
|
151
|
+
});
|
|
@@ -54,6 +54,9 @@ type _PascalCasedPropertiesDeep<Value, Options extends Required<CamelCaseOptions
|
|
|
54
54
|
: Value extends Array<infer U>
|
|
55
55
|
? Array<_PascalCasedPropertiesDeep<U, Options>>
|
|
56
56
|
: Value extends Set<infer U>
|
|
57
|
-
? Set<_PascalCasedPropertiesDeep<U, Options>>
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
? Set<_PascalCasedPropertiesDeep<U, Options>>
|
|
58
|
+
: Value extends object
|
|
59
|
+
? {
|
|
60
|
+
[K in keyof Value as PascalCase<K, Options>]: _PascalCasedPropertiesDeep<Value[K], Options>;
|
|
61
|
+
}
|
|
62
|
+
: Value;
|