From 1d618dfb01a21f02c4f41b1e0f347ed5c2fd8003 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 29 Sep 2022 15:51:12 -0400 Subject: [PATCH 1/2] fix(types): make schema.plugin() more flexible for schemas that don't define any generics Fix #12454 Re: #12139 --- test/types/plugin.test.ts | 7 +++++++ types/index.d.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/types/plugin.test.ts b/test/types/plugin.test.ts index 3bc39f4c9c9..06e209fd2d2 100644 --- a/test/types/plugin.test.ts +++ b/test/types/plugin.test.ts @@ -59,10 +59,17 @@ const testSchema = new Schema('Test', testSchema); diff --git a/types/index.d.ts b/types/index.d.ts index 5ffa2f25abf..4f0d8467e10 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -264,7 +264,7 @@ declare module 'mongoose' { pathType(path: string): string; /** Registers a plugin for this schema. */ - plugin, POptions extends Parameters[1] = Parameters[1]>(fn: PFunc, opts?: POptions): this; + plugin, POptions extends Parameters[1] = Parameters[1]>(fn: PFunc, opts?: POptions): this; /** Defines a post hook for the model. */ post>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction): this; From 2b0d4292b13dba6538a3759aa75f06dfbf7f7740 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Fri, 30 Sep 2022 11:58:36 -0400 Subject: [PATCH 2/2] fix(types): make PluginFunction slightly more strict re: comments on #12486 --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 4f0d8467e10..ba560b634dd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -264,7 +264,7 @@ declare module 'mongoose' { pathType(path: string): string; /** Registers a plugin for this schema. */ - plugin, POptions extends Parameters[1] = Parameters[1]>(fn: PFunc, opts?: POptions): this; + plugin, POptions extends Parameters[1] = Parameters[1]>(fn: PFunc, opts?: POptions): this; /** Defines a post hook for the model. */ post>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, fn: PostMiddlewareFunction): this;