Created
October 24, 2019 18:23
-
-
Save Willmo36/20f4668218f301f2bca0499c8f1f1932 to your computer and use it in GitHub Desktop.
Monocle-ts nested ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Lens } from 'monocle-ts' | |
type Foo = { | |
bar?: { | |
baz?: number[] | |
} | |
} | |
const bar = Lens.fromNullableProp<Foo>()('bar', {}) | |
const baz = Lens.fromNullableProp<Foo['bar']>()("baz", []) | |
const foo:Foo = { | |
bar: { | |
baz: [] | |
}, | |
}; | |
const result = bar.compose(baz).get(foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment