Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yup v1 support #508

Closed
Systerr opened this issue Feb 13, 2023 · 12 comments · Fixed by #520
Closed

Yup v1 support #508

Systerr opened this issue Feb 13, 2023 · 12 comments · Fixed by #520
Labels
question Further information is requested

Comments

@Systerr
Copy link

Systerr commented Feb 13, 2023

Hi. For now react-hook-form/resolvers supports yup v0.32
But recently yup v1 was released.

It contain breaking changes jquense/yup#1906

Will be good to have support of yup v1 too

@bluebill1049 bluebill1049 added the question Further information is requested label Feb 13, 2023
@bluebill1049
Copy link
Member

I don't think those breaking changes affect us. Could you try it out and let us know?

@AlexanderBadak
Copy link

I tried and ran into an issue regarding ObjectSchema type matching.

type Resolver extends only Yup.AnyObjectSchema butI think it should be Yup.ObjectSchema or at least both.

@jbpenrath
Copy link

It appears that types are broken.

node_modules/@hookform/resolvers/yup/dist/types.d.ts:3:23 - error TS2307: Cannot find module 'yup/lib/Lazy' or its corresponding type declarations.

3 import type Lazy from 'yup/lib/Lazy';
                        ~~~~~~~~~~~~~~

node_modules/@hookform/resolvers/yup/dist/types.d.ts:4:78 - error TS2344: Type 'T["validate"]' does not satisfy the constraint '(...args: any) => any'.

4 declare type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<T['validate']>[1];
                                                                               ~~~~~~~~~~~~~

node_modules/@hookform/resolvers/yup/dist/types.d.ts:4:78 - error TS2536: Type '"validate"' cannot be used to index type 'T'.

4 declare type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<T['validate']>[1];
                                                                               ~~~~~~~~~~~~~


Found 3 errors in the same file, starting at: node_modules/@hookform/resolvers/yup/dist/types.d.ts:3

@eucciferri
Copy link

Hi!

I also have a problem with yup v1 and yupResolver

image

@Svish
Copy link

Svish commented Mar 8, 2023

Upgrading to yup@1 not possible for us either until this gets fixed.

For a transition period, maybe a separate resolver for this new version could be added while marking the old one as deprecated somehow?

@slashwhatever
Copy link

Definitely breaking changes.

There's no longer an exported SchemaOf and trying to just change that to ObjectSchema as you would with v1 yup, generates even more TS errors

@jorisre
Copy link
Member

jorisre commented Mar 17, 2023

Ola guys 👋🏻 Feel free to review :)
#520

@Svish
Copy link

Svish commented Mar 20, 2023

Any estimate on when this change could be released?

(I suppose it should be a major change, as it's a breaking change for yup 🤔)

@jorisre
Copy link
Member

jorisre commented Mar 20, 2023

We'll release a major with severals changes including for yup resolver. We're working on it with @bluebill1049

@ethanhoroschak
Copy link

It appears that types are broken.

node_modules/@hookform/resolvers/yup/dist/types.d.ts:3:23 - error TS2307: Cannot find module 'yup/lib/Lazy' or its corresponding type declarations.

3 import type Lazy from 'yup/lib/Lazy';
                        ~~~~~~~~~~~~~~

node_modules/@hookform/resolvers/yup/dist/types.d.ts:4:78 - error TS2344: Type 'T["validate"]' does not satisfy the constraint '(...args: any) => any'.

4 declare type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<T['validate']>[1];
                                                                               ~~~~~~~~~~~~~

node_modules/@hookform/resolvers/yup/dist/types.d.ts:4:78 - error TS2536: Type '"validate"' cannot be used to index type 'T'.

4 declare type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<T['validate']>[1];
                                                                               ~~~~~~~~~~~~~


Found 3 errors in the same file, starting at: node_modules/@hookform/resolvers/yup/dist/types.d.ts:3

Was there a fix to the import type Lazy from 'yup/lib/Lazy'; issue? I see it is no longer exported by Yup v1

@jorisre
Copy link
Member

jorisre commented Mar 29, 2023

@ethanhoroschak Please open a new issue if it's yup resolver related. It seems to be related to Yup itself

@ethanhoroschak
Copy link

@jorisre My mistake! Found the open issue for Yup if anyone else stumbles on this thread for the same search query: jquense/yup#1954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants