-
Notifications
You must be signed in to change notification settings - Fork 935
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
Compilation error when specifying an object with any field #2013
Comments
The type error is telling you what the problem is. You have a type that isn't compatible with the schema you wrote. Specifically your type wants testScalar to be required but your schema it's optional. |
@jquense Thanks.
I tried with this code but I got the same error (sure, I wrote function InnerTypeSchema(): yup.ObjectSchema<InnerType> {
return yup.object({
testScalar: yup.mixed().required()
// testScalar: yup.mixed().defined() also error
});
}
I hope we can reopen this issue 🙏 |
I think function InnerTypeSchema() {
return yup
.object({
testScalar: yup.mixed().defined() // also .required()
})
} |
It's not buggy, ObjectSchema has a lot of generics, that aren't filled in when you just use function InnerTypeSchema() {
return yup.object({
testScalar: yup.mixed().defined()
}) satisfies yup.ObjectSchema<InnerType>;
} |
@jquense I got it. |
Describe the bug
I get a compile error when I specify an object with any field. If this is the intended behavior, I would appreciate ideas on how to resolve this.
To Reproduce
Here is a minimal reproduction code that is based on your code:
https://codesandbox.io/s/inspiring-beaver-gu3m0f?file=/src/index.test.ts
Expected behavior
compilable
Platform (please complete the following information):
Additional context
Code-Hex/graphql-codegen-typescript-validation-schema#359 (comment)
The text was updated successfully, but these errors were encountered: