UNPKG

shallow-render

Version:

Shallow rendering test utility for Angular

9 lines (8 loc) 629 B
/** * Utility type that converts an object to recursively have optional properties. * This includes items an arrays and return values for functions. */ import { InputSignal, InputSignalWithTransform } from '@angular/core'; export type RecursivePartial<T> = Partial<{ [key in keyof T]: T[key] extends InputSignal<infer U> | InputSignalWithTransform<any, infer U> ? RecursivePartial<U> : T[key] extends (...a: Array<infer U>) => any ? (...a: Array<U>) => RecursivePartial<ReturnType<T[key]>> | ReturnType<T[key]> : T[key] extends Array<any> ? Array<RecursivePartial<T[key][number]>> : RecursivePartial<T[key]> | T[key]; }>;