Skip to content

Commit

Permalink
types: make SchemaType static setters property accessible in TypeSc…
Browse files Browse the repository at this point in the history
…ript

Fix #14879
  • Loading branch information
vkarpov15 committed Sep 10, 2024
1 parent 286ab98 commit c7f7273
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,3 +1634,7 @@ function gh14825() {
type SchemaType = InferSchemaType<typeof schema>;
expectAssignable<User>({} as SchemaType);
}

function gh14879() {
Schema.Types.String.setters.push((val?: unknown) => typeof val === 'string' ? val.trim() : val);
}
3 changes: 3 additions & 0 deletions types/schematypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

/** The class that Mongoose uses internally to instantiate this SchemaType's `options` property. */
OptionsConstructor: SchemaTypeOptions<T>;

Expand Down

0 comments on commit c7f7273

Please sign in to comment.