fix(forms): improve types of directive constructor arguments (#38944)

Prior to this change, the `validators` and `asyncValidators` fields of a few Forms directives
were typed as `any[]`. This commit updates the types and makes them consistent for all directives
in the Forms package.

BREAKING CHANGE:

Directives in the `@angular/forms` package used to have `any[]` as a type of `validators` and
`asyncValidators` arguments in constructors. Now these arguments are properly typed, so if your
code relies on directive constructor types it may require some updates to improve type safety.

PR Close #38944
This commit is contained in:
Andrew Kushnir
2020-09-22 18:00:37 -07:00
committed by Joey Perrott
parent 07a66fc4c2
commit 246de9aaad
10 changed files with 41 additions and 32 deletions

View File

@ -231,8 +231,9 @@ class CustomValidatorDirective implements Validator {
});
describe('addFormGroup', () => {
const matchingPasswordsValidator = (g: FormGroup) => {
if (g.controls['password'].value != g.controls['passwordConfirm'].value) {
const matchingPasswordsValidator = (g: AbstractControl) => {
const controls = (g as FormGroup).controls;
if (controls['password'].value != controls['passwordConfirm'].value) {
return {'differentPasswords': true};
} else {
return null;