You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.4.6
Node.js version
16.14
MongoDB server version
5.0.9
Description
When trying to remove item from one-to-many relation array usingh $pull getting the following type error:
C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
server/comment/CommentService.ts:117:9 - error TS2345: Argument of type '{ $pull: { comments: string; }; }' is not assignable to parameter of type 'UpdateWithAggregationPipeline | UpdateQuery<PostDocument> | undefined'.
The types of '$pull.comments' are incompatible between these types.
Type 'string' is not assignable to type 'FilterOperators<undefined> | Partial<Comment | undefined> | { text?: FilterOperators<string> | undefined; author?: FilterOperators<...> | undefined; ... 4 more ...; updatedAt?: FilterOperators<...> | undefined; }'.
117 {
~
118 $pull: { comments: commentId },
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119 },
~~~~~~~~~
at createTSError (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\index.ts:859:12)
at reportTSError (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\index.ts:863:19)
at getOutput (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\index.ts:1077:36)
at Object.compile (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\index.ts:1433:41)
at transformSource (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\esm.ts:400:37)
at C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\esm.ts:278:53
at async addShortCircuitFlag (C:\Users\wight\Documents\blog-template\node_modules\ts-node\src\esm.ts:409:15)
at async ESMLoader.load (node:internal/modules/esm/loader:359:20)
at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:47) {
diagnosticCodes: [ 2345 ]
}
It seems that the $push operator is broken too. Here is the error I faced while upgrading from 6.3.8 to 6.5.0:
error TS2322: Type 'PictureType[]' is not assignable to type 'PictureType | ArrayOperator<PictureType[]>'.
// Code
await Model.updateOne({ _id }, { $push: { pictures } });
Prerequisites
Mongoose version
6.4.6
Node.js version
16.14
MongoDB server version
5.0.9
Description
When trying to remove item from one-to-many relation array usingh $pull getting the following type error:
Originally reported here: #12049 (comment)
Steps to Reproduce
project link: wight554/blog-template#55
code snippet:
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: