-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
types/schematypes.d.ts
Outdated
@@ -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[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static setters: Function[]; | |
static setters: ((val?: unknown) => unknown)[]; |
i think it is better with known arguments, unless there are more arguments?
There was a problem hiding this comment.
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.
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