From d8d8246a63493218e559b942de90c5d979b6808c Mon Sep 17 00:00:00 2001 From: Phillip Huang Date: Tue, 2 Dec 2025 15:36:43 -0500 Subject: [PATCH] types: make PipelineStage generic to fix QueryFilter incompatibility --- types/models.d.ts | 4 ++-- types/pipelinestage.d.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/types/models.d.ts b/types/models.d.ts index 627666c24e8..e4e161623d3 100644 --- a/types/models.d.ts +++ b/types/models.d.ts @@ -303,8 +303,8 @@ declare module 'mongoose' { SessionStarter { new >(doc?: DocType, fields?: any | null, options?: AnyObject): THydratedDocumentType; - aggregate(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate>; - aggregate(pipeline: PipelineStage[]): Aggregate>; + aggregate(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate>; + aggregate(pipeline: PipelineStage[]): Aggregate>; /** Base Mongoose instance the model uses. */ base: Mongoose; diff --git a/types/pipelinestage.d.ts b/types/pipelinestage.d.ts index 1f549594dfe..6d08fae2d37 100644 --- a/types/pipelinestage.d.ts +++ b/types/pipelinestage.d.ts @@ -2,7 +2,7 @@ declare module 'mongoose' { /** * [Stages reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/#aggregation-pipeline-stages) */ - export type PipelineStage = + export type PipelineStage = | PipelineStage.AddFields | PipelineStage.Bucket | PipelineStage.BucketAuto @@ -19,7 +19,7 @@ declare module 'mongoose' { | PipelineStage.Limit | PipelineStage.ListSessions | PipelineStage.Lookup - | PipelineStage.Match + | PipelineStage.Match | PipelineStage.Merge | PipelineStage.Out | PipelineStage.PlanCacheStats @@ -114,7 +114,7 @@ declare module 'mongoose' { $facet: Record; } - export type FacetPipelineStage = Exclude; + export type FacetPipelineStage = Exclude, PipelineStage.CollStats | PipelineStage.Facet | PipelineStage.GeoNear | PipelineStage.IndexStats | PipelineStage.Out | PipelineStage.Merge | PipelineStage.PlanCacheStats>; export interface GeoNear { /** [`$geoNear` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/) */ @@ -182,9 +182,9 @@ declare module 'mongoose' { } } - export interface Match { + export interface Match { /** [`$match` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/) */ - $match: QueryFilter; + $match: QueryFilter; } export interface Merge {