vtils

Home > types > PathValue

PathValue type

获取对象的路径值。最多支持 7 级路径。

Signature:

export declare type PathValue<T, L extends Path<T, L>> = L extends PathArray<T, L> ? PathArrayValue<T, L> : L extends keyof T ? T[L] : any;

References: Path

Example

function get<T, L extends Path<T, L>>(
  object: T,
  path: L,
): PathValue<T, L> {
  // ...
}