mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(forms): eagerly initialize data members (#44292)
Data members in AbstractControl should be eagerly initialized to address issue/24571. This eliminates the need to constantly check for truthiness and makes code much more readable. More PRs to follow to address issue/24571. PR Close #44292
This commit is contained in:
committed by
Dylan Hunn
parent
f058109284
commit
ca5b9b558c
@@ -168,8 +168,7 @@ function isOptionsObj(validatorOrOpts?: ValidatorFn|ValidatorFn[]|AbstractContro
|
||||
*/
|
||||
export abstract class AbstractControl {
|
||||
/** @internal */
|
||||
// TODO(issue/24571): remove '!'.
|
||||
_pendingDirty!: boolean;
|
||||
_pendingDirty = false;
|
||||
|
||||
/**
|
||||
* Indicates that a control has its own pending asynchronous validation in progress.
|
||||
@@ -179,15 +178,13 @@ export abstract class AbstractControl {
|
||||
_hasOwnPendingAsyncValidator = false;
|
||||
|
||||
/** @internal */
|
||||
// TODO(issue/24571): remove '!'.
|
||||
_pendingTouched!: boolean;
|
||||
_pendingTouched = false;
|
||||
|
||||
/** @internal */
|
||||
_onCollectionChange = () => {};
|
||||
|
||||
/** @internal */
|
||||
// TODO(issue/24571): remove '!'.
|
||||
_updateOn!: FormHooks;
|
||||
_updateOn?: FormHooks;
|
||||
|
||||
private _parent: FormGroup|FormArray|null = null;
|
||||
private _asyncValidationSubscription: any;
|
||||
@@ -298,7 +295,6 @@ export abstract class AbstractControl {
|
||||
* These status values are mutually exclusive, so a control cannot be
|
||||
* both valid AND invalid or invalid AND disabled.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly status!: FormControlStatus;
|
||||
|
||||
/**
|
||||
@@ -369,7 +365,6 @@ export abstract class AbstractControl {
|
||||
* An object containing any errors generated by failing validation,
|
||||
* or null if there are no errors.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly errors!: ValidationErrors|null;
|
||||
|
||||
/**
|
||||
@@ -415,7 +410,6 @@ export abstract class AbstractControl {
|
||||
* the UI or programmatically. It also emits an event each time you call enable() or disable()
|
||||
* without passing along {emitEvent: false} as a function argument.
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly valueChanges!: Observable<any>;
|
||||
|
||||
/**
|
||||
@@ -426,7 +420,6 @@ export abstract class AbstractControl {
|
||||
* @see {@link AbstractControl.status}
|
||||
*
|
||||
*/
|
||||
// TODO(issue/24571): remove '!'.
|
||||
public readonly statusChanges!: Observable<FormControlStatus>;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user