From 221cbd0b47e272bda86d49870ff7e3bb70775dc2 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 13 Jun 2019 21:24:31 +0200 Subject: [PATCH] refactor(forms): ensure compatibility with typescript strict flag (#30993) As part of FW-1265, the `@angular/forms` package is made compatible with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html) PR Close #30993 --- packages/forms/src/directives/shared.ts | 6 +++--- packages/forms/src/model.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/forms/src/directives/shared.ts b/packages/forms/src/directives/shared.ts index 282be9901a..f40274a653 100644 --- a/packages/forms/src/directives/shared.ts +++ b/packages/forms/src/directives/shared.ts @@ -140,12 +140,12 @@ function _throwError(dir: AbstractControlDirective, message: string): void { throw new Error(`${message} ${messageEnd}`); } -export function composeValidators(validators: Array): ValidatorFn|null { +export function composeValidators(validators: Array): ValidatorFn|null { return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null; } -export function composeAsyncValidators(validators: Array): AsyncValidatorFn| - null { +export function composeAsyncValidators(validators: Array): + AsyncValidatorFn|null { return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) : null; } diff --git a/packages/forms/src/model.ts b/packages/forms/src/model.ts index 0b446b2b18..04d7e6a25e 100644 --- a/packages/forms/src/model.ts +++ b/packages/forms/src/model.ts @@ -52,7 +52,7 @@ function _find(control: AbstractControl, path: Array| string, del } if (path instanceof Array && (path.length === 0)) return null; - return (>path).reduce((v: AbstractControl, name) => { + return (>path).reduce((v: AbstractControl | null, name) => { if (v instanceof FormGroup) { return v.controls.hasOwnProperty(name as string) ? v.controls[name] : null; }