Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
type ExtractValuesRecusrively<T> = T extends FormState<infer U>
? { [K in keyof U]: ExtractValuesRecusrively<U[K]> }
: T extends FieldState<infer V>
? V
: never;
// vs
type ExtractValuesRecusrively<State> = State extends FormState<infer InnerForm>
? { [FieldKey in keyof InnerForm]: ExtractValuesRecusrively<InnerForm[FieldKey]> }
: State extends FieldState<infer FieldType>
? FieldType
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment