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

Investigate NODE-3936 - TypeScript error on `Filter` on 4.3.1

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed

      NODE-3936 Description

      What problem are you facing?

      Project fails to compile after upgrade to 4.3.1.

      What driver and relevant dependency versions are you using?

      mongodb 4.3.1

      Typescript 4.5.5

      Steps to reproduce?

      The following code

      interface User {
        _id: string;
        name: string;
      }
      
      function stringFilter(q: unknown): Filter<User> {
        const query: Filter<User> = {};
        if (q && typeof q === "string") {
          query.$text = {
            $search: q,
            $caseSensitive: false,
            $diacriticSensitive: false,
            $language: "en",
          };
        }
        return query;
      }
      
      const query = stringFilter("search");
      let results = collection.find(query);
      

      gives the error "Property '$text' does not exist on type 'Filter<User>'. Property '$text' does not exist on type 'Partial<User>'."

      It worked on 4.3.0.

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            dbeng-pm-bot PM Bot
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: