-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Optional Arguments in SchemaTypes.path().cast required by Typescript #14748
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
They are required fields according to the the docs here: https://mongoosejs.com/docs/api/schematype.html#SchemaType.prototype.cast() |
vkarpov15
added a commit
that referenced
this issue
Jul 26, 2024
types: allow calling `SchemaType.cast()` without `parent` and `init` parameters
This was referenced Aug 21, 2024
This was referenced Aug 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
7.6.7
Node.js version
18.20.3
MongoDB server version
7.0.12
Typescript version (if applicable)
5.2.2
Description
It looks like the typescript signature for SchemaTypes.path().cast require some (what appear to be) optional fields.
I wanted to create a subdocument instance without creating a model. With reference to #9076,
I had
which works exactly as intended with the //@ts-ignore, but otherwise gives me a type error. Upon further examination,
it appears that
doc and init are required fields in the typescript signature, whereas they seem to be optional in a lot of the documentation I've seen.
This is my top-level schema file:
Please let me know if I'm mistaken somewhere, many thanks!!
Steps to Reproduce
Please see above.
Expected Behavior
Optional (?) fields should be required by typescript signature
The text was updated successfully, but these errors were encountered: