question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'message' does not exist on type 'DeepMap<String, FieldError>'.

See original GitHub issue

Hi,

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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kodebotcommented, Aug 6, 2020

why do you use String with capital S in your interface? If you can use primitive type string it seems to resolve your problem

1reaction
anthonyhexiumcommented, Aug 6, 2020

Oh my god … 😞 Thanks. I missed that.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found