(
// formState and defaultValue will only be null if T is nullable
formState: FormControlState<TValue> | TValue = null as unknown as TValue,
validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,
asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
)
| 467 | _pendingChange: boolean = false; |
| 468 | |
| 469 | constructor( |
| 470 | // formState and defaultValue will only be null if T is nullable |
| 471 | formState: FormControlState<TValue> | TValue = null as unknown as TValue, |
| 472 | validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, |
| 473 | asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null, |
| 474 | ) { |
| 475 | super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts)); |
| 476 | this._applyFormState(formState); |
| 477 | this._setUpdateStrategy(validatorOrOpts); |
| 478 | this._initObservables(); |
| 479 | this.updateValueAndValidity({ |
| 480 | onlySelf: true, |
| 481 | // If `asyncValidator` is present, it will trigger control status change from `PENDING` to |
| 482 | // `VALID` or `INVALID`. |
| 483 | // The status should be broadcasted via the `statusChanges` observable, so we set |
| 484 | // `emitEvent` to `true` to allow that during the control creation process. |
| 485 | emitEvent: !!this.asyncValidator, |
| 486 | }); |
| 487 | if ( |
| 488 | isOptionsObj(validatorOrOpts) && |
| 489 | (validatorOrOpts.nonNullable || validatorOrOpts.initialValueIsDefault) |
| 490 | ) { |
| 491 | if (isFormControlState(formState)) { |
| 492 | this.defaultValue = formState.value; |
| 493 | } else { |
| 494 | this.defaultValue = formState; |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | override setValue( |
| 500 | value: TValue, |
nothing calls this directly
no test coverage detected