import { Lens } from '../types/types' ; /**
 * A lens for zooming in on an object's property. The setter will remove the key
 * if the value is undefined.
 */ export const objectProp = < S , A , Key extends keyof A > ( key ) : Lens < S , A , Omit < A , Key > extends A ? A [ Key ] | undefined : undefined extends A [ Key ] ? never : A [ Key ] > => ( { get , set } ) => ( { get : ( ) => get ( ) [ key ] as any , set : ( propValue ) => { const { ... copy } = get ( ) ; if ( propValue === undefined ) { delete copy [ key ] ; } else { copy [ key ] = propValue as A [ Key ] ; } return set ( copy ) ; } , } ) ;