UNPKG

property-string-path

Version:

Generate type safe dot paths to object properties based on an interface.

8 lines (6 loc) 541 B
declare type Primitive = string | number | bigint | boolean | undefined | symbol; declare type PropertyStringPath<T, Prefix = ''> = { [K in keyof T]: K extends 'valueOf' | 'toString' ? never : T[K] extends Primitive | Array<any> ? `${string & Prefix}${string & K}` : `${string & Prefix}${string & K}` | PropertyStringPath<T[K], `${string & Prefix}${string & K}.`>; }[keyof T]; declare function propertyStringPathFactory<T, R = string>(): (path: PropertyStringPath<T>) => R; export { PropertyStringPath, propertyStringPathFactory };