refactor(forms): remove unnecessary `!` operators from validators (#36805)

When we added the strict null checks, the lexer had some `!` operators added to prevent the compilation from failing.

See #24571

PR Close #36805
This commit is contained in:
danranVm 2020-04-25 11:42:18 +08:00 committed by Andrew Scott
parent 421e807f80
commit 5fd2c8f2d6
1 changed files with 16 additions and 26 deletions

View File

@ -158,10 +158,8 @@ export const CHECKBOX_REQUIRED_VALIDATOR: StaticProvider = {
host: {'[attr.required]': 'required ? "" : null'} host: {'[attr.required]': 'required ? "" : null'}
}) })
export class RequiredValidator implements Validator { export class RequiredValidator implements Validator {
// TODO(issue/24571): remove '!'. private _required = false;
private _required!: boolean; private _onChange?: () => void;
// TODO(issue/24571): remove '!'.
private _onChange!: () => void;
/** /**
* @description * @description
@ -274,10 +272,8 @@ export const EMAIL_VALIDATOR: any = {
providers: [EMAIL_VALIDATOR] providers: [EMAIL_VALIDATOR]
}) })
export class EmailValidator implements Validator { export class EmailValidator implements Validator {
// TODO(issue/24571): remove '!'. private _enabled = false;
private _enabled!: boolean; private _onChange?: () => void;
// TODO(issue/24571): remove '!'.
private _onChange!: () => void;
/** /**
* @description * @description
@ -368,17 +364,15 @@ export const MIN_LENGTH_VALIDATOR: any = {
host: {'[attr.minlength]': 'minlength ? minlength : null'} host: {'[attr.minlength]': 'minlength ? minlength : null'}
}) })
export class MinLengthValidator implements Validator, OnChanges { export class MinLengthValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'. private _validator: ValidatorFn = Validators.nullValidator;
private _validator!: ValidatorFn; private _onChange?: () => void;
// TODO(issue/24571): remove '!'.
private _onChange!: () => void;
/** /**
* @description * @description
* Tracks changes to the the minimum length bound to this directive. * Tracks changes to the the minimum length bound to this directive.
*/ */
// TODO(issue/24571): remove '!'. @Input()
@Input() minlength!: string|number; minlength!: string|number; // This input is always defined, since the name matches selector.
/** /**
* @description * @description
@ -456,17 +450,15 @@ export const MAX_LENGTH_VALIDATOR: any = {
host: {'[attr.maxlength]': 'maxlength ? maxlength : null'} host: {'[attr.maxlength]': 'maxlength ? maxlength : null'}
}) })
export class MaxLengthValidator implements Validator, OnChanges { export class MaxLengthValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'. private _validator: ValidatorFn = Validators.nullValidator;
private _validator!: ValidatorFn; private _onChange?: () => void;
// TODO(issue/24571): remove '!'.
private _onChange!: () => void;
/** /**
* @description * @description
* Tracks changes to the the maximum length bound to this directive. * Tracks changes to the the maximum length bound to this directive.
*/ */
// TODO(issue/24571): remove '!'. @Input()
@Input() maxlength!: string|number; maxlength!: string|number; // This input is always defined, since the name matches selector.
/** /**
* @description * @description
@ -547,17 +539,15 @@ export const PATTERN_VALIDATOR: any = {
host: {'[attr.pattern]': 'pattern ? pattern : null'} host: {'[attr.pattern]': 'pattern ? pattern : null'}
}) })
export class PatternValidator implements Validator, OnChanges { export class PatternValidator implements Validator, OnChanges {
// TODO(issue/24571): remove '!'. private _validator: ValidatorFn = Validators.nullValidator;
private _validator!: ValidatorFn; private _onChange?: () => void;
// TODO(issue/24571): remove '!'.
private _onChange!: () => void;
/** /**
* @description * @description
* Tracks changes to the pattern bound to this directive. * Tracks changes to the pattern bound to this directive.
*/ */
// TODO(issue/24571): remove '!'. @Input()
@Input() pattern!: string|RegExp; pattern!: string|RegExp; // This input is always defined, since the name matches selector.
/** /**
* @description * @description