New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncValidatorFn can be passed as ValidatorFn to FormControl without warning #48676
Labels
Milestone
Comments
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Jan 10, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
4 tasks
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Jan 10, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Jan 10, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
💀💀 |
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Jan 24, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Mar 25, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
JeanMeche
added a commit
to JeanMeche/angular
that referenced
this issue
Mar 26, 2023
With this commit, AsyncValidatorFn cannot be passed as ValidatorFn anymore in FormControl. fixes: angular#48676
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
Today the one of the 5 constructors of FormControl looks like this :
The problem is that the compilator won't mind when passing an
AsyncValidatorFn
as 2nd parameter but the validation will always error sinceAsyncValidatorFn
doesn't returnnull
.The root case is that
ValidatorFn
returns a very loose typeValidationErrors
:{ [key: string]: any}
.Observable<any>
orPromise<any>
are validValidationErrors
.Repro on Stackblitz
Proposed solution
Improve the typings of
ValidationErrors
or somehow makeAsyncValidatorFn
&ValidatorFn
incompatible for example: withtype ValidatorFn = (control: AbstractControl) => (ValidationErrors & { then?: never, subscribe?: never}) | null;
Demo on playground
Alternatives considered
Devs should be better at reading the apis :(
The text was updated successfully, but these errors were encountered: