You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to get the correct typing information when I have a nested form group?
In the following example, I have to implement the following workaround in order to get the "correct" type for the orderLine form group.
formGroup=inject(RxFormBuilder).formGroup(RefundOrderLineModel)asIFormGroup<RefundOrderLineModel>;// hack: need to use as any as IFormGroup<OrderLineModel> to get correct typing informationgetorderLineFormGroup(){returnthis.formGroup.controls.orderLineasanyasIFormGroup<OrderLineModel>;}classRefundOrderLineModel{
@propObject(OrderLineModel)orderLine=newOrderLineModel();}classOrderLineModel{
@prop()quantity=0;}
This is no good.
This doesn't compile.
The expected solution you would like
I'd like the compiler to see this.formGroup.controls.orderLine as an IFormGroup<OrderLineModel>, or at least be able to cast to it without as any. Ideally, types would be inferred without anyas keywords. Or an alternative solution which has correct inferred types.
Describe the problem statement?
How to get the correct typing information when I have a nested form group?
In the following example, I have to implement the following workaround in order to get the "correct" type for the
orderLine
form group.This is no good.
![image](https://private-user-images.githubusercontent.com/59396813/318123783-d0bb79f2-9e7d-472e-b78e-1737def17c86.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MDQ2MjQsIm5iZiI6MTcyMTcwNDMyNCwicGF0aCI6Ii81OTM5NjgxMy8zMTgxMjM3ODMtZDBiYjc5ZjItOWU3ZC00NzJlLWI3OGUtMTczN2RlZjE3Yzg2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDAzMTIwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTczMTlhOGVhNGI1N2UxOGJiOTQwMmNlNjlhYWRhN2U1YTRkMGMzOWY5NjhmMDQ3MDhkNzEwOTRjYzI0NDg3Y2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.o3JUkZZmrrrDr4ZosxUq60_-rD-mWlFSG5Mfz0S_EDc)
This doesn't compile.
![image](https://private-user-images.githubusercontent.com/59396813/318123875-b1cca16d-4de8-4caf-9ab1-a13fed1e3971.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MDQ2MjQsIm5iZiI6MTcyMTcwNDMyNCwicGF0aCI6Ii81OTM5NjgxMy8zMTgxMjM4NzUtYjFjY2ExNmQtNGRlOC00Y2FmLTlhYjEtYTEzZmVkMWUzOTcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDAzMTIwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQwODkzNTE1ODg3MTMyMTZjMzg1MDZlNWZkMDVlYjc2OGI0ZjQ5YzU0MDlmZmNmODM5ZmQ5NzQwMjI5MTlkMGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.N8yHgbMD7MYOnWYquaOBjYvjphF0r3kVChZ1oUlfxqA)
The expected solution you would like
I'd like the compiler to see
this.formGroup.controls.orderLine
as anIFormGroup<OrderLineModel>
, or at least be able to cast to it withoutas any
. Ideally, types would be inferred without anyas
keywords. Or an alternative solution which has correct inferred types.Url
n/a
Package version
"@rxweb/reactive-form-validators": "^13.0.1",
"@rxweb/types": "^1.0.8",
The text was updated successfully, but these errors were encountered: