UNPKG

@flex-development/tutils

Version:
17 lines (16 loc) 702 B
/** * @file Type Definitions - PathValue * @module tutils/types/PathValue */ import type ObjectPlain from './object-plain.mjs'; import type Path from './path.mjs'; /** * Constructs a type representing a property value of `T`. * * @see https://github.com/ghoullier/awesome-template-literal-types#dot-notation-string-type-safe * * @template T - Object type * @template P - Object path (dot notation friendly) */ declare type PathValue<T extends ObjectPlain, P extends Path<T> = Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never; export { type PathValue as default };