Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4664

TypeScript compilation fails when calling bulkWrite with $addToSet on a field that is specified in the filter and TSchema = any

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: TypeScript
    • Labels:
    • 1

      What problem are you facing?

      The following script fails to compile. Admittedly it is a strange example, but Mongoose users have run into this issue before: https://github.com/Automattic/mongoose/pull/12167

      import { UpdateOneModel, Document } from 'mongodb';
        
      const op: UpdateOneModel<Document> = {
        filter: {
          arr: {
            $nin: ['abc']
          }
        },
        update: { 
          $addToSet: {
            arr: 'abc'
          }
        }
      };
      

      What driver and relevant dependency versions are you using?

      TypeScript 4.8.3. Node driver 4.9.1.

      Steps to reproduce?

      Run `tsc test.ts` with the above script.

            Assignee:
            Unassigned Unassigned
            Reporter:
            val@karpov.io Valeri Karpov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: