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

`StrictFilter` and `StrictMatchKeysAndValues` types not working as expected

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

      What problem are you facing?

      Trying to upgrade to the v5 Mongo driver and am running into some unexpected behavior with the new `StrictFilter` and `StrictMatchKeysAndValues` util types for potentially undefined types

      What driver and relevant dependency versions are you using?

      `mongodb@5.5.0`

      Steps to reproduce?

      ```
      type TestNestedType = { value?:

      { nestedValue:string }

      }

      const test:StrictMatchKeysAndValues<TestNestedType> =

      { 'value.nestedValue': false, // no type error }

      ```

      When a type is potentially undefined, these new strict types seem to return an `unknown` type

      When the type is not optional, the types work as expected 

      ```
      type TestNestedType = { value:

      { nestedValue:string }

      }

      const test:StrictMatchKeysAndValues<TestNestedType> =

      { 'value.nestedValue': false,  // type error }

      ```

       

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            rileybrowndev96@gmail.com Riley Brown
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: