|
1 | | -import type {ApplyDefaultOptions, BuiltIns} from './internal/index.d.ts'; |
| 1 | +import type {ApplyDefaultOptions, BuiltIns, HasMultipleCallSignatures} from './internal/index.d.ts'; |
2 | 2 | import type {IsNever} from './is-never.d.ts'; |
3 | 3 |
|
4 | 4 | /** |
@@ -99,16 +99,20 @@ export type PartialDeep<T, Options extends PartialDeepOptions = {}> = |
99 | 99 |
|
100 | 100 | type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) |
101 | 101 | ? T |
102 | | - : IsNever<keyof T> extends true // For functions with no properties |
103 | | - ? T |
104 | | - : T extends Map<infer KeyType, infer ValueType> |
105 | | - ? PartialMapDeep<KeyType, ValueType, Options> |
106 | | - : T extends Set<infer ItemType> |
107 | | - ? PartialSetDeep<ItemType, Options> |
108 | | - : T extends ReadonlyMap<infer KeyType, infer ValueType> |
109 | | - ? PartialReadonlyMapDeep<KeyType, ValueType, Options> |
110 | | - : T extends ReadonlySet<infer ItemType> |
111 | | - ? PartialReadonlySetDeep<ItemType, Options> |
| 102 | + : T extends Map<infer KeyType, infer ValueType> |
| 103 | + ? PartialMapDeep<KeyType, ValueType, Options> |
| 104 | + : T extends Set<infer ItemType> |
| 105 | + ? PartialSetDeep<ItemType, Options> |
| 106 | + : T extends ReadonlyMap<infer KeyType, infer ValueType> |
| 107 | + ? PartialReadonlyMapDeep<KeyType, ValueType, Options> |
| 108 | + : T extends ReadonlySet<infer ItemType> |
| 109 | + ? PartialReadonlySetDeep<ItemType, Options> |
| 110 | + : T extends (...arguments_: any[]) => unknown |
| 111 | + ? IsNever<keyof T> extends true |
| 112 | + ? T // For functions with no properties |
| 113 | + : HasMultipleCallSignatures<T> extends true |
| 114 | + ? T |
| 115 | + : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> |
112 | 116 | : T extends object |
113 | 117 | ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156 |
114 | 118 | ? Options['recurseIntoArrays'] extends true |
@@ -144,11 +148,8 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = { |
144 | 148 | /** |
145 | 149 | Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`. |
146 | 150 | */ |
147 | | -type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = |
148 | | - (ObjectType extends (...arguments_: any) => unknown |
149 | | - ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> |
150 | | - : {}) & ({ |
151 | | - [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> |
152 | | - }); |
| 151 | +type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { |
| 152 | + [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> |
| 153 | +}; |
153 | 154 |
|
154 | 155 | export {}; |
0 commit comments