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: make SchemaType static setters property accessible in TypeScript #14881

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14879

Summary

There are places in the docs where we recommend pushing default setters to schematypes like mongoose.Schema.String.setters.push(fn), but TypeScript types currently don't support that.

Examples

@vkarpov15 vkarpov15 added this to the 8.6.2 milestone Sep 10, 2024
@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Sep 11, 2024
@@ -216,6 +216,9 @@ declare module 'mongoose' {
/** Attaches a getter for all instances of this schema type. */
static get(getter: (value: any) => any): void;

/** Array containing default setters for all instances of this SchemaType */
static setters: Function[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
static setters: Function[];
static setters: ((val?: unknown) => unknown)[];

i think it is better with known arguments, unless there are more arguments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, there's technically 4 arguments: val, priorVal, doc, options. I'll fix.

@vkarpov15 vkarpov15 merged commit dd7e75e into master Sep 11, 2024
5 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-14879 branch September 11, 2024 15:48
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.

Setters property of schema types not available in TS declarations
2 participants