Object.path doesn't handle nullable and optional values correctly at last hop.
Object.Path<{nullable: number | null | undefined}, ['nullable']>
Expected code above to return number | null | undefined, since this is the value at the path. Returns number in v6.3.0
I've tried swapping the order of operations between NonNullable and At, which I believe solves this problem, but it causes tests for O.MergeUp and O.Nullable to fail and I'm not sure I understand why.
type __Path<O, Path extends List<Key>, strict extends Boolean, I extends Iteration = IterationOf<'0'>> = {
- 0: __Path<NonNullable<At<O & {}, Path[Pos<I>], strict>>, Path, strict, Next<I>>
+ 0: __Path<At<NonNullable<O> & {}, Path[Pos<I>], strict>, Path, strict, Next<I>>
1: O // Use of `NonNullable` otherwise path cannot be followed #`undefined`
}[Extends<Pos<I>, Length<Path>>]
Hi @smoogly, thanks for reporting this. There's a strict option that is supposed to handle that:
type test = Path<{nullable: number | null | undefined}, ['nullable'], 0>
But it does not behave like you said. So I'm going to fix this.
Your fix is out in a few minutes, thanks!