import { AddGroupControlAction } from '../actions' ; import { formGroupReducer } from '../group/reducer' ; import { FormGroupState , isGroupState , KeyValue } from '../state' ; import { ensureState } from './util' ; /**
 * This update function takes a name and a value and returns a projection function
 * that adds a child control with the given name and value to a form group state.
 */ export function addGroupControl < TValue extends KeyValue , TControlKey extends keyof TValue = keyof TValue > ( name , value ) ; /**
 * This update function takes a form group state, a name, and a value, and adds a child
 * control with the given name and value to the form group state.
 */ export function addGroupControl < TValue extends KeyValue , TControlKey extends keyof TValue = keyof TValue > ( state , name , value ) ; export function addGroupControl < TValue extends KeyValue , TControlKey extends keyof TValue = keyof TValue > ( nameOrState , valueOrName , value ? ) { if ( isGroupState ( nameOrState ) ) { return formGroupReducer ( nameOrState , new AddGroupControlAction < TValue , TControlKey > ( nameOrState . id , valueOrName as TControlKey , value ! ) ) ; } return ( s ) => addGroupControl ( ensureState ( s ) , nameOrState as TControlKey , valueOrName as TValue [ TControlKey ] ) ; }