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
This commit is contained in:
Paul Gschwendtner 2019-06-13 21:24:31 +02:00 committed by Miško Hevery
parent ce9d0de840
commit 221cbd0b47
2 changed files with 4 additions and 4 deletions

View File

@ -140,12 +140,12 @@ function _throwError(dir: AbstractControlDirective, message: string): void {
throw new Error(`${message} ${messageEnd}`);
}
export function composeValidators(validators: Array<Validator|Function>): ValidatorFn|null {
export function composeValidators(validators: Array<Validator|ValidatorFn>): ValidatorFn|null {
return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null;
}
export function composeAsyncValidators(validators: Array<Validator|Function>): AsyncValidatorFn|
null {
export function composeAsyncValidators(validators: Array<AsyncValidator|AsyncValidatorFn>):
AsyncValidatorFn|null {
return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) :
null;
}

View File

@ -52,7 +52,7 @@ function _find(control: AbstractControl, path: Array<string|number>| string, del
}
if (path instanceof Array && (path.length === 0)) return null;
return (<Array<string|number>>path).reduce((v: AbstractControl, name) => {
return (<Array<string|number>>path).reduce((v: AbstractControl | null, name) => {
if (v instanceof FormGroup) {
return v.controls.hasOwnProperty(name as string) ? v.controls[name] : null;
}