-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
FormGroup<T> doesn't have the correct types in some cases #107
Comments
Thanks for the report. The author of this is no longer associated with Angular. I will look into it when I have time. |
Ah, I see. Is this project heading towards being abandoned? I'm trying to decide if it is "safe" to use this for brand-new projects, or if I should steer clear. Thanks! |
I'm going to write everything from scratch. I recommend waiting for this. It's coming soon. |
I am closing this issue as I released v3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm submitting a...
First, this project is fantastic, and I love it! I'm reporting a few issues I've found with the types of controls on a FormGroup.
Current behavior
Consider this model:
And this code to create a FormGroup using FormBuilder:
Expected behavior
I should be able to bind an input to the createDate control like this:
But this gives an error because the type of createDate is actually
AbstractControl<Date>
and notFormControl<Date>
.Casting it to
any
works fine though, like this:Next, FormArray members do not seem to have the correct type inferred. Using the same starting code as above, I would expect to be able to iterate the array member of my form group like this:
However,
bars
has typeAbstractControl<BarForm[], any>
instead ofFormArray<BarForm>
. I can use a helper to cast it to the correct type, then I'm able to iterate it just fine:Finally, each control within
FormArray<BarForm>
is of typeAbstractControl<BarForm>
instead of typeFormGroup<BarForm>
. I can see why that would be the case, but it would be awesome if it returned the actual FormGroup type.Minimal reproduction of the problem with instructions
I've made a Stackblitz showing the issues. Note that my workarounds are applied so that the code will compile.
https://stackblitz.com/edit/angular-ivy-w5uadp
What is the motivation / use case for changing the behavior?
Returning more-correct types allows for a nicer coding experience and enables strongly-typed binding and enumeration in views, which is awesome! 🙂
Environment
Again, awesome library, thank you for providing it, and please let me know if I can provide any other info.
The text was updated successfully, but these errors were encountered: