Optional type wrapper that uses proxies for
short curcuiting evaluation of deeply nested
nullable properties. This is something like
elvis operator in Swift/Kotlin/Rust where
you can write
if (a.b?.c == null) { ... }
example
type T = { x?: { y?: { z?: number } } }
const t = Optional.make<T>({});
console.log(x.y.z.valueOf()); // nullconsole.log(x.y.valueOf()); // nullconst t1 = Optional.of({
x: {
y: {
z: 10
}
}
})
console.log(x.y.z.valueOf()); // 10
Optional type wrapper that uses proxies for short curcuiting evaluation of deeply nested nullable properties. This is something like elvis operator in Swift/Kotlin/Rust where you can write
if (a.b?.c == null) { ... }
type T = { x?: { y?: { z?: number } } } const t = Optional.make<T>({}); console.log(x.y.z.valueOf()); // null console.log(x.y.valueOf()); // null const t1 = Optional.of({ x: { y: { z: 10 } } }) console.log(x.y.z.valueOf()); // 10