@@ -172,35 +172,14 @@ type DeepRecord<T> = {
172172 [ K in DeepKeysAndValues < T > as K [ 'lookup' ] ] : K [ 'value' ]
173173}
174174
175- type DeepValueImpl <
176- TDeepRecord extends DeepRecord < unknown > ,
177- TAccessor extends DeepKeys < unknown > ,
178- > = TDeepRecord [ TAccessor ] extends never
179- ? TDeepRecord [ AddEnd < TAccessor > ]
180- : TDeepRecord [ TAccessor ]
181-
182175/**
183176 * Infer the type of a deeply nested property within an object or an array.
184177 */
185178export type DeepValue < TValue , TAccessor extends string > = unknown extends TValue
186179 ? TValue
187- : TAccessor extends DeepKeys < TValue >
188- ? DeepValueImpl < DeepRecord < TValue > , TAccessor >
189- : never
190-
191- type Foo = {
192- a : string
193- b : number
194- c : { d : string }
195- }
196- type RecordExample = {
197- records : Record < string , Foo >
198- }
199-
200- type E1 = DeepKeys < RecordExample >
201- type E2 = DeepRecord < RecordExample >
202-
203- type FooValue2 = DeepValue < RecordExample , 'records.something' >
180+ : TAccessor extends keyof DeepRecord < TValue >
181+ ? DeepRecord < TValue > [ TAccessor ]
182+ : DeepRecord < TValue > [ AddEnd < TAccessor > ]
204183
205184/**
206185 * The keys of an object or array, deeply nested and only with a value of TValue
@@ -225,3 +204,12 @@ export type FieldsMap<TFormData, TFieldGroupData> =
225204 TFieldGroupData [ K ]
226205 >
227206 }
207+
208+ type Foo = {
209+ a : string
210+ b : number
211+ c : { d : string }
212+ }
213+ type RecordExample = {
214+ records : Record < string , Foo >
215+ }
0 commit comments