DeepValue

Type Alias: DeepValue<TValue, TAccessor, TDepth>

ts
type DeepValue<TValue, TAccessor, TDepth> = unknown extends TValue ? TValue : TDepth["length"] extends 10 ? unknown : TValue extends ReadonlyArray<any> ? TAccessor extends `[${infer TBrackets}].${infer TAfter}` ? DeepValue<DeepValue<TValue, TBrackets, [...TDepth, any]>, TAfter, [...TDepth, any]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends keyof TValue ? TValue[TAccessor] : TValue[TAccessor & number] : TAccessor extends `${infer TBefore}[${infer TEverythingElse}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, `[${TEverythingElse}`, [...TDepth, any]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends `${infer TBefore}.${infer TAfter}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, TAfter, [...TDepth, any]> : TAccessor extends string ? 
  | Get<TValue, TAccessor>
  | ApplyNull<...> | ApplyUndefined<...> : never;
type DeepValue<TValue, TAccessor, TDepth> = unknown extends TValue ? TValue : TDepth["length"] extends 10 ? unknown : TValue extends ReadonlyArray<any> ? TAccessor extends `[${infer TBrackets}].${infer TAfter}` ? DeepValue<DeepValue<TValue, TBrackets, [...TDepth, any]>, TAfter, [...TDepth, any]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends keyof TValue ? TValue[TAccessor] : TValue[TAccessor & number] : TAccessor extends `${infer TBefore}[${infer TEverythingElse}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, `[${TEverythingElse}`, [...TDepth, any]> : TAccessor extends `[${infer TBrackets}]` ? DeepValue<TValue, TBrackets, [...TDepth, any]> : TAccessor extends `${infer TBefore}.${infer TAfter}` ? DeepValue<DeepValue<TValue, TBefore, [...TDepth, any]>, TAfter, [...TDepth, any]> : TAccessor extends string ? 
  | Get<TValue, TAccessor>
  | ApplyNull<...> | ApplyUndefined<...> : never;

Defined in: packages/form-core/src/util-types.ts:104

Infer the type of a deeply nested property within an object or an array.

Type Parameters

TValue

TAccessor

TDepth extends ReadonlyArray<any> = []

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.