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

Optional Arguments in SchemaTypes.path().cast required by Typescript #14748

Open
2 tasks done
iamjackchen opened this issue Jul 15, 2024 · 0 comments
Open
2 tasks done

Comments

@iamjackchen
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

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
image

which works exactly as intended with the //@ts-ignore, but otherwise gives me a type error. Upon further examination,
it appears that
image
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:
image

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

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

1 participant