@@ -1,16 +1,16 @@
1import cn from 'classnames';
1import cn from 'classnames';
2import React from 'react';
2import React from 'react';
3−import { LiteralUnion, RegisterOptions, useFormContext } from 'react-hook-form';
3+import { FieldValues, LiteralUnion, RegisterOptions, useFormContext } from 'react-hook-form';
5type Validation = LiteralUnion<keyof RegisterOptions, string>;
5type Validation = LiteralUnion<keyof RegisterOptions, string>;
7−interface ErrorMessageProps<T> {
7+interface ErrorMessageProps<T extends FieldValues> {
8 field: keyof T;
8 field: keyof T;
9 messages: Partial<Record<Validation, string>>;
9 messages: Partial<Record<Validation, string>>;
10 className?: string;
10 className?: string;
13−export function ErrorMessage<T>({ field, messages, className }: ErrorMessageProps<T>) {
13+export function ErrorMessage<T extends FieldValues>({ field, messages, className }: ErrorMessageProps<T>) {
14 const { formState } = useFormContext<T>();
14 const { formState } = useFormContext<T>();
15 const error = formState.errors[field];
15 const error = formState.errors[field];