rimeto/ts-optchain

Traversing Nullable Types

beeequeue opened this issue · 0 comments

This package is very useful when it comes to traversing optional chains, and therefore seems to have a good structure set up for the types.
Would it be possible to add some kind of OC type that allows for nullable type traversal?

e.g.

interface Foo {
  bar?: {
    biz?: {
      baz?: string
    }
  }
}

type Baz = Foo["bar"]["biz"]["baz"]
                      ^ "biz" does not exist on type "{ biz?: ... } | undefined"

type GoodBaz = OC<Foo, "bar", "biz", "baz"> // string | undefined