From ed1eb003ae55bd9cc6cd234b154259241d197386 Mon Sep 17 00:00:00 2001 From: mohammad0-0ahmad Date: Tue, 29 Mar 2022 23:51:32 +0200 Subject: [PATCH] Refactor statics & methods props in SchemaOptions. --- test/types/document.test.ts | 2 +- test/types/schema.test.ts | 4 ++-- types/schemaoptions.d.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 28b4355e878..88397983a60 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -183,6 +183,6 @@ function m0_0aDocument() { /* Document-Methods-tests */ /* -------------------------------------------------------------------------- */ - expectType>(AutoTypeModelInstance.instanceFn()); + expectType>(new AutoTypedModel().instanceFn()); } \ No newline at end of file diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts index b372d25cc79..83f6f471972 100644 --- a/test/types/schema.test.ts +++ b/test/types/schema.test.ts @@ -1,4 +1,4 @@ -import { Schema, Document, SchemaDefinition, Model, Types, InferSchemaType, SchemaType, Query } from 'mongoose'; +import { Schema, Document, SchemaDefinition, Model, Types, InferSchemaType, SchemaType, Query, HydratedDocument } from 'mongoose'; import { expectType, expectError, expectAssignable } from 'tsd'; enum Genre { @@ -445,7 +445,7 @@ export function autoTypedSchema() { }, methods: { instanceFn() { - expectAssignable>(this); + expectType>(this); return 'Returned from DocumentInstanceFn' as const; } }, diff --git a/types/schemaoptions.d.ts b/types/schemaoptions.d.ts index d33f628dc35..66ce9739cd7 100644 --- a/types/schemaoptions.d.ts +++ b/types/schemaoptions.d.ts @@ -11,7 +11,7 @@ declare module 'mongoose' { type TypeKeyBaseType = string; type DefaultTypeKey = 'type'; - interface SchemaOptions { + interface SchemaOptions { /** * By default, Mongoose's init() function creates all the indexes defined in your model's schema by * calling Model.createIndexes() after you successfully connect to MongoDB. If you want to disable @@ -192,12 +192,12 @@ declare module 'mongoose' { /** * Model Statics methods. */ - statics?: Record>(this: T, ...args: any) => unknown> | StaticMethods, + statics?: Record, ...args: any) => unknown> | StaticMethods, /** * Document instance methods. */ - methods?: Record>(this: T, ...args: any) => unknown> | InstanceMethods, + methods?: Record, ...args: any) => unknown> | InstanceMethods, /** * Query helper functions