resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

TypeScript error after upgrading to >= v3.1.1

Open ThomasSertorio opened this issue 2 years ago • 6 comments
trafficstars

Describe the bug I am building a form with a "dynamic" Yup schema. According to some user actions, the set of inputs to fill in is selected among different choices. I have this "working" with @hookform/resolvers 3.1.0 but when upgrading to 3.1.1 or above, I get a TypeScript error on the resolver type.

To Reproduce Step to reproduce the behavior:

  • Go to the codesandbox: https://codesandbox.io/s/serene-glitter-lct3zp?file=/src/App.tsx
  • See the TypeScript error l56
  • Go to package.json and downgrade to 3.1.0
  • No Typescript Error and the form is working (click on Activate Form X)

Codesandbox link (Required) Sandbox: https://codesandbox.io/s/serene-glitter-lct3zp?file=/src/App.tsx

Desktop (please complete the following information):

  • OS: [Ventura 13.5.2]
  • Browser [Chrome]
  • Version [117]

ThomasSertorio avatar Sep 22 '23 12:09 ThomasSertorio

I wanted to create an issue regarding this error but turns out there is already this one. However, I have already created a playground to showcase this error. Perhaps my playground would be easier to understand.

Codesandbox link: https://codesandbox.io/s/relaxed-chatterjee-p5scpp?file=/src/App.tsx.

Steps to reproduce the error:

  • open the playground, the linked version uses @hookform/resolvers library v3.0.0 - this version works just fine
  • update the version of the library to the latest one - at the time of writing it is v3.3.1
  • an error will appear on line 47 - where the resolver is defined

SCR-20231003-kkaj

nikita-lepikhin avatar Oct 03 '23 09:10 nikita-lepikhin

Yeah, the mentioned issue occurs also in my project

eslint-any-error

Callenowy avatar Oct 07 '23 12:10 Callenowy

Hi, thank you for the great library, any ideas on how to fix this ? meanwhile rolled back to 3.0.0

crow7m avatar Oct 12 '23 21:10 crow7m

Ran into this myself recently.

Yup v1.* has a compiler flag requirement.

You must have the strictNullChecks compiler option enabled for type inference to work. https://github.com/jquense/yup#typescript-configuration

I also defined my schema and typed it using the ObjectSchema generic which accepts the expected object structure inside of it. https://github.com/jquense/yup#ensuring-a-schema-matches-an-existing-type


Versions:

@hookform/resolvers 3.3.2
react-hook-form 7.47.0
yup 1.3.2

mpash avatar Oct 18 '23 21:10 mpash

It looks like this issue is gone after upgrading @hookform/resolvers to the latest version.

Callenowy avatar Oct 22 '23 00:10 Callenowy

The issue is gone for me after updated to the latest version as well.

jilv220 avatar Oct 29 '23 00:10 jilv220