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

types: allow calling SchemaType.cast() without parent and init parameters #14756

Merged
merged 3 commits into from
Jul 26, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14748
Re: #9076

Summary

The doc and init parameters to cast() should be optional in TypeScript, we have plenty of tests that call SchemaType.prototype.cast() with only 1 arg. Plus #9076 recommends using Schema.Types.Subdocument.prototype.cast() as an alternative for instantiating a subdocument without an associated parent document, which is the root cause of the issue in #14748.

Examples

@vkarpov15 vkarpov15 added this to the 8.5.2 milestone Jul 21, 2024
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.

Looks good, some slight suggestions

test/types/schema.test.ts Outdated Show resolved Hide resolved
test/types/schema.test.ts Show resolved Hide resolved
@vkarpov15 vkarpov15 requested a review from hasezoey July 23, 2024 16:38
@vkarpov15
Copy link
Collaborator Author

@hasezoey please take a look at the new implementation, I added a test based on your comments, and also some more logic to allow passing DocType down to the Schema Subdocument class

@vkarpov15 vkarpov15 merged commit 2badd9e into master Jul 26, 2024
27 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-14748 branch July 26, 2024 21:35
@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Jul 27, 2024
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.

Optional Arguments in SchemaTypes.path().cast required by Typescript
2 participants