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

Type error for property validate from Reference does not exist as response from reach #2152

Open
juancarlosjr97 opened this issue Dec 26, 2023 · 1 comment

Comments

@juancarlosjr97
Copy link

Describe the bug

The TypeScript type definitions for the validate method on reach() return seem to be missing, resulting in a compilation error.

To Reproduce

Project to reproduce the type error: https://github.com/juancarlosjr97/yup-schema-validation-reach/blob/main/index.ts#L7

The error on TypeScript is

Property 'validate' does not exist on type 'Reference<string> | ISchema<string, AnyObject, any, any>'.
  Property 'validate' does not exist on type 'Reference<string>'.ts(2339)

Expected behavior

No type error for reach when trying to run validate

Platform (please complete the following information):

  • TypeScript 5.3.3
  • Version 1.3.3
@oarodrig
Copy link

oarodrig commented Mar 7, 2024

Seeing this as well. We used to be able to use yup.reach(MySchema).isValidSync(), but now it seems that the type returned is Reference<T> | ISchema<T, AnyObject, any, any> as noted above, instead of a Schema. We're currently casting the result of reach into a Schema as a workaround, but is there any guidance on this?

edit: Mine is a separate issue. Since reach now returns a Reference or an ISchema, I think you can get away with narrowing the type by using Reference.isRef, if you don't want to cast the result.

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

No branches or pull requests

2 participants