I am learning TypeScript and am still fairly new to it, and am attempting to digest this bit of code from the react-hook-form (library?) that is being deprecated.
I was lead to the declaration of this code as I am receiving the error
Argument of type 'UnpackNestedValue<PathValue<ControlType, Path<ControlType>>>' is not assignable to parameter of type 'PathValue<ControlType, Path<ControlType>>'.
Could someone kindly explain what it is doing? I am struggling to make sense of it.
export declare type UnpackNestedValue<T> = T extends NestedValue<infer U> ? U : T extends Date | FileList | File | Blob ? T : T extends object ? {
[K in keyof T]: UnpackNestedValue<T[K]>;
} : T;