UNPKG

houseform

Version:

Simple to use React forms, where your validation and UI code live together in harmony.

7 lines (6 loc) 490 B
type AnyArray<T> = Array<T> | ReadonlyArray<T>; type ObjectMapDeep<Obj extends object, MappedType> = { [key in keyof Obj]: Obj[key] extends AnyArray<infer Q> ? Array<MapDeep<Q, MappedType>> : Exclude<Obj[key], undefined> extends object ? Obj[key] extends Exclude<Obj[key], undefined> ? MapDeep<Obj[key], MappedType> : MapDeep<Obj[key], MappedType> | undefined : MappedType; }; export type MapDeep<Obj, MappedType> = Obj extends object ? ObjectMapDeep<Obj, MappedType> : Obj; export {};