Skip to content

Commit

Permalink
fix(index.d.ts): make SchemaTypeOptions a class, add missing `SchemaT…
Browse files Browse the repository at this point in the history
…ype#OptionsConstructor`

Fix #10001
  • Loading branch information
vkarpov15 committed Mar 18, 2021
1 parent 12767f9 commit 7edde3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ declare module 'mongoose' {

type Unpacked<T> = T extends (infer U)[] ? U : T;

interface SchemaTypeOptions<T> {
export class SchemaTypeOptions<T> {
type?:
T extends string | number | Function ? SchemaDefinitionWithBuiltInClass<T> :
T extends Schema<any> ? T :
Expand Down Expand Up @@ -2536,6 +2536,9 @@ declare module 'mongoose' {
/** Attaches a getter for all instances of this schema type. */
static get(getter: (value: any) => any): void;

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

/** Cast `val` to this schema type. Each class that inherits from schema type should implement this function. */
cast(val: any, doc: Document<any>, init: boolean): any;

Expand Down
2 changes: 1 addition & 1 deletion lib/schematype.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function SchemaType(path, options, instance) {
}

/*!
* ignore
* The class that Mongoose uses internally to instantiate this SchemaType's `options` property.
*/

SchemaType.prototype.OptionsConstructor = SchemaTypeOptions;
Expand Down

0 comments on commit 7edde3f

Please sign in to comment.