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

Typescript: Type Lazy is missing the following properties from type BaseSchema #1146

Closed
IvanKalinin opened this issue Dec 4, 2020 · 1 comment

Comments

@IvanKalinin
Copy link

Describe the bug
In yup 0.32 type Lazy in incompatible with type BaseSchema

To Reproduce

steps: Yup.object().shape({
    childNodes: Yup.array().of(
      Yup.object().shape({
        meta: Yup.object().shape({
          data: Yup.object().shape({
            name: Yup.string().required('Step name is a required field'),
            type: Yup.string().required('Step type is a required field'),
          }),
        }),
        childNodes: Yup.array().of(
          Yup.lazy((value: any): any => {
            if (value.title === 'Requests:') {
              return Yup.object().shape({ childNodes: Yup.array().of(RequestsSchema) });
            }
            return Yup.object().shape({ childNodes: Yup.array().of(TargetSchema) });
          })
        ),
      })
    ),
  }),

Expected behavior
No types error

I removed @types/yup, upgraded to yup 0.32.1, added "strictFunctionTypes": false, "strictNullChecks": true in tsconfig.json

image

image

image

@bilsak18
Copy link

bilsak18 commented Oct 28, 2021

Thanks to this comment, I made it work.

I agree that putting casting as any is not the best solution, but at least it gets the job done.

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