11import type { ApplyDefaultOptions , BuiltIns , HasMultipleCallSignatures } from './internal/index.d.ts' ;
2+ import type { Simplify } from './simplify.d.ts' ;
23import type { IsNever } from './is-never.d.ts' ;
34
45/**
@@ -97,33 +98,34 @@ partialShape.dimensions = [15]; // OK
9798export type PartialDeep < T , Options extends PartialDeepOptions = { } > =
9899 _PartialDeep < T , ApplyDefaultOptions < PartialDeepOptions , DefaultPartialDeepOptions , Options > > ;
99100
100- type _PartialDeep < T , Options extends Required < PartialDeepOptions > > = T extends BuiltIns | ( ( new ( ...arguments_ : any [ ] ) => unknown ) )
101- ? T
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 >
116- : T extends object
117- ? T extends ReadonlyArray < infer ItemType > // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
118- ? Options [ 'recurseIntoArrays' ] extends true
119- ? ItemType [ ] extends T // Test for arrays (non-tuples) specifically
120- ? readonly ItemType [ ] extends T // Differentiate readonly and mutable arrays
121- ? ReadonlyArray < _PartialDeep < Options [ 'allowUndefinedInNonTupleArrays' ] extends false ? ItemType : ItemType | undefined , Options > >
122- : Array < _PartialDeep < Options [ 'allowUndefinedInNonTupleArrays' ] extends false ? ItemType : ItemType | undefined , Options > >
123- : PartialObjectDeep < T , Options > // Tuples behave properly
124- : T // If they don't opt into array testing, just use the original type
125- : PartialObjectDeep < T , Options >
126- : unknown ;
101+ type _PartialDeep < T , Options extends Required < PartialDeepOptions > > =
102+ T extends BuiltIns | ( ( new ( ...arguments_ : any [ ] ) => unknown ) )
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 >
112+ : T extends ( ...arguments_ : any [ ] ) => unknown
113+ ? IsNever < keyof T > extends true
114+ ? T // For functions with no properties
115+ : HasMultipleCallSignatures < T > extends true
116+ ? T
117+ : ( ( ...arguments_ : Parameters < T > ) => ReturnType < T > ) & PartialObjectDeep < T , Options >
118+ : T extends object
119+ ? T extends ReadonlyArray < infer ItemType > // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
120+ ? Options [ 'recurseIntoArrays' ] extends true
121+ ? ItemType [ ] extends T // Test for arrays (non-tuples) specifically
122+ ? readonly ItemType [ ] extends T // Differentiate readonly and mutable arrays
123+ ? ReadonlyArray < _PartialDeep < Options [ 'allowUndefinedInNonTupleArrays' ] extends false ? ItemType : ItemType | undefined , Options > >
124+ : Array < _PartialDeep < Options [ 'allowUndefinedInNonTupleArrays' ] extends false ? ItemType : ItemType | undefined , Options > >
125+ : PartialObjectDeep < T , Options > // Tuples behave properly
126+ : T // If they don't opt into array testing, just use the original type
127+ : PartialObjectDeep < T , Options >
128+ : unknown ;
127129
128130/**
129131Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
@@ -148,8 +150,8 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
148150/**
149151Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
150152*/
151- type PartialObjectDeep < ObjectType extends object , Options extends Required < PartialDeepOptions > > = {
153+ type PartialObjectDeep < ObjectType extends object , Options extends Required < PartialDeepOptions > > = Simplify < {
152154 [ KeyType in keyof ObjectType ] ?: _PartialDeep < ObjectType [ KeyType ] , Options >
153- } ;
155+ } > ;
154156
155157export { } ;
0 commit comments