Help Simplifying this Type

Can anyone help me simplify this so that I only need to specify the 2nd parameter. Key and Key2 are always the same, I just needed to add additional constraints to Key and this was the only way I could figure out how to do it. FieldValues, ArrayPath, PathValue, and Control are all from react-hook-form if it matters.
type WebhookPath<FormType extends FieldValues, Key extends ArrayPath<FormType>> = PathValue<
FormType,
Key
> extends WebhookModel[]
? Key
: never;

export interface WebhookOptionsProps<
FormType extends FieldValues,
Key extends ArrayPath<FormType>,
Key2 extends WebhookPath<FormType, Key>
> {
path: Key2;
control: Control<FormType>;
}
type WebhookPath<FormType extends FieldValues, Key extends ArrayPath<FormType>> = PathValue<
FormType,
Key
> extends WebhookModel[]
? Key
: never;

export interface WebhookOptionsProps<
FormType extends FieldValues,
Key extends ArrayPath<FormType>,
Key2 extends WebhookPath<FormType, Key>
> {
path: Key2;
control: Control<FormType>;
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server