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

Fixed InferSchemaType nullable arrays type inference #12441

Closed

Conversation

lpizzinidev
Copy link
Contributor

fixes #12420

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Sep 18, 2022
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -69,7 +69,7 @@ type IsPathRequired<P, TypeKey extends TypeKeyBaseType> =
P extends { required: true | [true, string | undefined] } | ArrayConstructor | any[]
? true
: P extends (Record<TypeKey, ArrayConstructor | any[]>)
? P extends { default: undefined }
? P extends { default: undefined } | { required: false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments here: #12420 (comment) . We shouldn't rely on required: false, because required is false by default anyway. We instead need to check if default is a function that returns undefined.

@vkarpov15
Copy link
Collaborator

I'm going to close this since the PR isn't going in the right direction, and now has merge conflicts.

@vkarpov15 vkarpov15 closed this Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mongoose.InferSchemaType does not correctly infer nullable arrays
3 participants