felte icon indicating copy to clipboard operation
felte copied to clipboard

`$errors` store type signature is incorrect with yup validator

Open AydanGaite opened this issue 3 years ago • 0 comments

Describe the bug

When an array does not contain .required() the type signature of the $errors store becomes incorrect.

  const schema = yup.object({
    calculations: yup.array(yup.object({
      label: yup.string().required(),
    })),
  });

This is my schema. When I attempt to access $errors.calculations.[index].label typescript gives me a type error–Property 'label' does not exist on type 'string'. When I add .required() to the root of calculations the type signature is considered to be correct

 const schema = yup.object({
   calculations: yup.array(yup.object({
     label: yup.string().required(),
   })).required(),
 });

Same error applies when using notRequired()

Which package/s are you using?

felte (Svelte), @felte/validator-yup

Environment

  • OS: macOS 12.3
  • Browser: Chrome 102.0.5005.115
  • Version: 1.2.2

To reproduce

No response

Small reproduction example

No response

Screenshots

Screen Shot 2022-07-17 at 1 45 53 AM (2)

Screen Shot 2022-07-17 at 1 45 43 AM (2)

Screen Shot 2022-07-17 at 1 45 24 AM (2)

Additional context

No response

AydanGaite avatar Jul 17 '22 08:07 AydanGaite