gparlakov/forms-typed

Order the TypedArray types

gparlakov opened this issue · 0 comments

export interface TypedFormArray<K extends Array<T> = any[], T = any> extends FormArray {

export interface TypedFormArray<T = any, K extends Array<T> = T[]> extends FormArray {
    valueChanges: Observable<K>;
    statusChanges: Observable<'VALID' | 'INVALID' | 'PENDING' | 'DISABLED'>;

    controls: Array<TypedFormControl<T>>;
  export interface TypedFormArray<K extends Array<T> = any[], T = any> extends For
 * c.patchValue(['s']) // expects string[]
 * c.patchValue(1) //  COMPILE TIME! type error!
 */
export function typedFormArray<K extends Array<T> = any[], T = any>(

export function typedFormArray<T = any, K extends Array<T> = any[]>(
    controls: Array<TypedFormControl<T>>,
    validatorOrOptions?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null,
    asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[] | null
): TypedFormArray<K, T> {

): TypedFormArray<T, K> {
    // tslint:disable-next-line: prefer-type-cast
    return new FormArray(controls, validatorOrOptions, asyncValidators) as any;
}