Skip to content

Commit

Permalink
feat: common type
Browse files Browse the repository at this point in the history
  • Loading branch information
NaveOWO committed Dec 18, 2023
1 parent a6a3945 commit f7195ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { FieldValues, useForm } from "react-hook-form";

export type Unpack<T> = T extends (infer U)[] ? U : T;

export type RegisterOption<TFieldValues extends FieldValues> = Parameters<
ReturnType<typeof useForm<TFieldValues>>["register"]
> extends [unknown, ...infer U]
? Unpack<U>
: never;

0 comments on commit f7195ae

Please sign in to comment.