import { AbstractControl } from '@angular/forms' ; import { Observable , Subject } from 'rxjs' ; /**
 * Extract arguments of function
 */ export type ArgumentsType < F > = F extends ( ... args : infer A ) => any ? A : never ; /**
 * Creates an object like O. Optionally provide minimum set of properties P which the objects must share to conform
 */ export type ObjectLike < O extends object , P extends keyof O = keyof O > = Pick < O , P > ; param control see https export const extractTouchedChanges = ( control ) : Observable < boolean > => { const prevMarkAsTouched = control . markAsTouched ; const prevMarkAsUntouched = control . markAsUntouched ; const touchedChanges$ = new Subject < boolean > ( ) ; function nextMarkAsTouched ( ... args ) { touchedChanges$ . next ( true ) ; prevMarkAsTouched . bind ( control ) ( ... args ) ; } function nextMarkAsUntouched ( ... args ) { touchedChanges$ . next ( false ) ; prevMarkAsUntouched . bind ( control ) ( ... args ) ; } control . markAsTouched = nextMarkAsTouched ; control . markAsUntouched = nextMarkAsUntouched ; return touchedChanges$ ; } ; param control export const extractPristineChanges = ( control ) : Observable < boolean > => { const prevMarkAsPristine = control . markAsPristine ; const prevMarkAsDirty = control . markAsDirty ; const pristineChanges$ = new Subject < boolean > ( ) ; function nextMarkAsPristine ( ... args ) { pristineChanges$ . next ( true ) ; prevMarkAsPristine . bind ( control ) ( ... args ) ; } function nextMarkAsDirty ( ... args ) { pristineChanges$ . next ( false ) ; prevMarkAsDirty . bind ( control ) ( ... args ) ; } control . markAsPristine = nextMarkAsPristine ; control . markAsDirty = nextMarkAsDirty ; return pristineChanges$ ; } ;