UNPKG

typed-reflector

Version:

Metadata reflector with typing support.

10 lines (9 loc) 678 B
export declare type StringDict = Record<string, any>; export declare type Key<T> = keyof T & string; export declare type ArrayValueMap<AM extends StringDict> = { [K in keyof AM]: AM[K][]; }; export declare type ArrayValue<AM extends StringDict, K extends Key<ArrayValueMap<AM>>> = ArrayValueMap<AM>[K]; export declare type MergeKey<M extends StringDict, AM extends StringDict> = Key<M> | Key<AM>; export declare type GenericMap<M extends StringDict, AM extends StringDict> = M & ArrayValueMap<AM>; export declare type MapValue<M extends StringDict, AM extends StringDict, K extends MergeKey<M, AM>> = K extends Key<AM> ? ArrayValue<AM, K> : K extends Key<M> ? M[K] : never;