1 | /**
|
2 | * @since 0.5.0
|
3 | */
|
4 | import * as t from 'io-ts'
|
5 | import { Lens } from 'monocle-ts'
|
6 | /**
|
7 | * @since 0.5.0
|
8 | */
|
9 | export interface ExactHasLenses extends t.ExactType<HasLenses> {}
|
10 | /**
|
11 | * @since 0.5.0
|
12 | */
|
13 | export declare type HasLenses = t.InterfaceType<any> | ExactHasLenses
|
14 | /**
|
15 | * Return a `Lens` for each prop
|
16 | *
|
17 | * @example
|
18 | * import * as t from 'io-ts'
|
19 | * import { getLenses } from 'io-ts-types/lib/getLenses'
|
20 | *
|
21 | * const Person = t.type({
|
22 | * name: t.string,
|
23 | * age: t.number
|
24 | * })
|
25 | *
|
26 | * const lenses = getLenses(Person)
|
27 | * assert.strictEqual(lenses.age.get({ name: 'Giulio', age: 44 }), 44)
|
28 | *
|
29 | * @since 0.5.0
|
30 | */
|
31 | export declare function getLenses<C extends HasLenses>(
|
32 | codec: C
|
33 | ): {
|
34 | [K in keyof t.TypeOf<C>]: Lens<t.TypeOf<C>, t.TypeOf<C>[K]>
|
35 | }
|