1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Why is updateOn gives error no overload matches this call?

Discussão em 'Angular' iniciado por Eem, Julho 1, 2025.

  1. Eem

    Eem Guest

    I try to set updateOn and validators for a FormControl:

    valueControl = new FormControl({value: '', disabled: true, updateOn: 'blur'}, [
    Validators.required, Validators.pattern(/^([+-]?[\d\.,]+)(\([+-]?[\d\.,]+\))?([eE][+-]?\d+)?$/i),
    ]);


    I get this error on updateOn:

    No overload matches this call.
    Overload 1 of 5, '(value: string | FormControlState<string>, opts: FormControlOptions & { nonNullable: true; }): FormControl<string>', gave the following error.
    Object literal may only specify known properties, and 'updateOn' does not exist in type 'FormControlState<string>'.
    Overload 2 of 5, '(value: string | FormControlState<string>, opts: FormControlOptions & { initialValueIsDefault: true; }): FormControl<string>', gave the following error.
    Object literal may only specify known properties, and 'updateOn' does not exist in type 'FormControlState<string>'.
    Overload 3 of 5, '(value: string | FormControlState<string>, validatorOrOpts?: FormControlOptions | ValidatorFn | ValidatorFn[] | null | undefined, asyncValidator?: AsyncValidatorFn | ... 2 more ... | undefined): FormControl<...>', gave the following error.
    Object literal may only specify known properties, and 'updateOn' does not exist in type 'FormControlState<string>'. [2769]


    I looked up other examples and everyone have it like this.

    For example:

    emailFormControl = new FormControl('', {
    validators: [Validators.required, Validators.email],
    updateOn: 'blur'
    });


    I try this example:

    measureValueControl = new FormControl('', {disabled: true, validators: [
    Validators.required, Validators.pattern(/^([+-]?[\d\.,]+)(\([+-]?[\d\.,]+\))?([eE][+-]?\d+)?$/i) ],
    updateOn: 'blur'});


    But now I get an error on disabled:

    No overload matches this call.
    Overload 1 of 5, '(value: string | FormControlState<string>, opts: FormControlOptions & { nonNullable: true; }): FormControl<string>', gave the following error.
    Object literal may only specify known properties, and 'disabled' does not exist in type 'FormControlOptions & { nonNullable: true; }'.
    Overload 2 of 5, '(value: string | FormControlState<string>, opts: FormControlOptions & { initialValueIsDefault: true; }): FormControl<string>', gave the following error.
    Object literal may only specify known properties, and 'disabled' does not exist in type 'FormControlOptions & { initialValueIsDefault: true; }'.
    Overload 3 of 5, '(value: string | FormControlState<string>, validatorOrOpts?: FormControlOptions | ValidatorFn | ValidatorFn[] | null | undefined, asyncValidator?: AsyncValidatorFn | ... 2 more ... | undefined): FormControl<...>', gave the following error.
    Object literal may only specify known properties, and 'disabled' does not exist in type 'FormControlOptions | ValidatorFn | ValidatorFn[]'. [2769]


    Angular 19

    Continue reading...

Compartilhe esta Página