Property 'message' does not exist on type 'DeepMap<String, FieldError>'.
See original GitHub issueHi,
I am using the library with TypeScript. And I am having a TypeScript error every time I want to access a message error.
interface LoginFormInput {
email: String;
password: String;
}
const schema = yup.object().shape({
email: yup.string().email('Veuillez saisir un e-mail valide !').required(),
password: yup.string().min(6, 'Votre mot de passe doit faire minimum 6 caractères !').required()
});
export default function Login() {
const { register, handleSubmit, errors } = useForm<LoginFormInput>({
resolver: yupResolver(schema)
});
const onSubmit = (data: LoginFormInput) => {
console.log(data);
};
return (
{errors.email && <p className="mt-2 text-sm text-red-600">{errors.email.message}</p>}
)
(I cleaned the code to have only the error part of course)
I could do (errors.email as any).message
but do you have a cleaner way ? Or am I missing something maybe.
Am I on the latests version of the library.
Thanks !
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
TS2339: Property 'message' does not exist on type 'object ...
Having a problem with using yup with react hook form for this image component getting an error message when setting my FormInputs type...
Read more >Property 'focus' does not exist on type 'Element' in TS
The error "Property 'focus' does not exist on type 'Element'" occurs when we try to call the focus() method on an element that...
Read more >How to fix 'Property does not exist on type Window in ...
If you've been asking 'How do I fix the "Property does not exist on type Window in TypeScript" error?' then this is the...
Read more >Property 'name' does not exist on type 'IPhysicsEnabledObject'
I've run into this issue in a few different areas when using Typescript. For some reason, Typescript says something doesn't exist when it ......
Read more >How to fix property not existing on EventTarget in TypeScript
target is possibly null . Property value does not exist on type EventTarget . TypeScript compiler error message. The first error occurs because ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
why do you use
String
with capitalS
in your interface? If you can use primitive typestring
it seems to resolve your problemOh my god … 😞 Thanks. I missed that.