diff --git a/test/types/expressions.test.ts b/test/types/expressions.test.ts index a078f3a0777..00509363c07 100644 --- a/test/types/expressions.test.ts +++ b/test/types/expressions.test.ts @@ -193,3 +193,13 @@ const nullExpr: Expression = { const nullNETupleExpr: Expression = { $ne: ['$name', null] }; + +const switchExpr: Expression.Switch = { + $switch: { + branches: [ + { case: { $eq: ['$name', 'Detlef'] }, then: 'Detlef' }, + { case: { $eq: ['$name', 'John'] }, then: 'John' } + ], + default: 'Hello' + } +}; diff --git a/types/expressions.d.ts b/types/expressions.d.ts index 10ee0bf1559..53a7ca7ce38 100644 --- a/types/expressions.d.ts +++ b/types/expressions.d.ts @@ -1067,13 +1067,13 @@ declare module 'mongoose' { * - $case * - $then */ - $branches: { $case: Expression, then: Expression }[]; + branches: { case: Expression, then: Expression }[]; /** * The path to take if no branch case expression evaluates to true. * * Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error. */ - $default: Expression; + default: Expression; }; }