import { AddArrayControlAction } from '../actions' ; import { formArrayReducer } from '../array/reducer' ; import { FormArrayState , isArrayState } from '../state' ; import { ensureState } from './util' ; /**
 * This update function takes a value and optionally an index and returns a projection function
 * that adds a child control at the given index or at the end of a form array state.
 */ export function addArrayControl < TValue > ( value , index ? ) ; /**
 * This update function takes an array form state, a value, and optionally an index and adds a
 * child control at the given index or at the end of the state.
 */ export function addArrayControl < TValue > ( state , value , index ? ) ; export function addArrayControl < TValue > ( valueOrState , indexOrValue , index ? ) { if ( isArrayState ( valueOrState ) ) { return formArrayReducer ( valueOrState , new AddArrayControlAction ( valueOrState . id , indexOrValue as TValue , index ) ) ; } return ( s ) => addArrayControl ( ensureState ( s ) , valueOrState as TValue , indexOrValue as number ) ; }