Title: Wrong FormControl type inference when created with FormBuild through group() with Validators and an array as value · Issue #46442 · angular/angular · GitHub
Open Graph Title: Wrong FormControl type inference when created with FormBuild through group() with Validators and an array as value · Issue #46442 · angular/angular
X Title: Wrong FormControl type inference when created with FormBuild through group() with Validators and an array as value · Issue #46442 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description When creating a FormGroup with the new ng14 FormBuilder, if you try to add a control with both array value and validator(s) the infered typ...
Open Graph Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description When creating a FormGroup with the new ng14 FormBuilder, if you try to add a control with both arra...
X Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description When creating a FormGroup with the new ng14 FormBuilder, if you try to add a control with both arra...
Opengraph URL: https://github.com/angular/angular/issues/46442
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong FormControl type inference when created with FormBuild through group() with Validators and an array as value ","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nforms\n\n### Is this a regression?\n\nNo\n\n### Description\n\nWhen creating a FormGroup with the new ng14 FormBuilder, if you try to add a control with both array value and validator(s) the infered type for this control become wrong. It seems the validator(s) are considered as value so we get a bad union typing.\r\n\r\n```ts\r\n/**\r\n * Wrong type!\r\n * FormGroup\u003c{\r\n * test: FormControl\u003cnumber[] | ((control: AbstractControl\u003cany, any>) => ValidationErrors | null)>;\r\n * }>\r\n */\r\nconst form = fb.nonNullable.group({\r\n test: [[1,2,3], Validators.required]\r\n})\r\n```\r\n\r\nIf you use the long way to add control, everything works just fine but we loose FormBuilder.group() shorthand synthax benefit\r\n\r\n```ts\r\n/**\r\n * Good type!\r\n * FormGroup\u003c{\r\n * test: FormControl\u003cnumber[]>;\r\n * }>\r\n */\r\nconst form = fb.nonNullable.group({\r\n test: fb.nonNullable.control([1,2,3], Validators.required)\r\n})\r\n```\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://stackblitz.com/edit/angular-ivy-cw97ml?file=src/app/app.component.ts\n\n### Please provide the exception or error you saw\n\n```true\nType 'FormGroup\u003c{ test: FormControl\u003cnumber[] | ((control: AbstractControl\u003cany, any>) => ValidationErrors)>; }>' is not assignable to type 'FormGroup\u003c{ test: FormControl\u003cnumber[]>; }>'.\r\n Types of property 'controls' are incompatible.\r\n Type '{ test: FormControl\u003cnumber[] | ((control: AbstractControl\u003cany, any>) => ValidationErrors)>; }' is not assignable to type '{ test: FormControl\u003cnumber[]>; }'.(2322)\n```\n\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI: 14.0.2\r\nNode: 16.15.1\r\nPackage Manager: npm 8.12.2 \r\nOS: linux x64\r\n\r\nAngular: 14.0.2\r\n... animations, cdk, cli, common, compiler, compiler-cli, core\r\n... forms, material, platform-browser, platform-browser-dynamic\r\n... router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1400.2\r\n@angular-devkit/build-angular 14.0.2\r\n@angular-devkit/core 14.0.2\r\n@angular-devkit/schematics 14.0.2\r\n@angular/flex-layout 13.0.0-beta.38\r\n@schematics/angular 14.0.2\r\nrxjs 7.5.5\r\ntypescript 4.7.4\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/Mikastark","@type":"Person","name":"Mikastark"},"datePublished":"2022-06-21T08:20:08Z","url":"https://github.com/angular/angular/issues/46442"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3fd77c89-ea2a-6aee-4676-13a9c341a796 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFAE:76F02:E7E9C0:12AB203:6B00FD80 |
| html-safe-nonce | 17ac79ac4a50a391d179759e57742242c3fd3a2f596208f77497bae353f9a930 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkFFOjc2RjAyOkU3RTlDMDoxMkFCMjAzOjZCMDBGRDgwIiwidmlzaXRvcl9pZCI6IjIxMjA2OTUyNzczNDUxMTE0MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e052ec597530cdac337e0e7c0565b89214a4cf16aba975c2663b4ef6dcfd3164 |
| hovercard-subject-tag | issue:1278078118 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/46442/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d90221a7f4bbf2a8ad2be7e899a99476f78e6be0112bfd1a2f5e0871b850dff/angular/angular/issues/46442 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d90221a7f4bbf2a8ad2be7e899a99476f78e6be0112bfd1a2f5e0871b850dff/angular/angular/issues/46442 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description When creating a FormGroup with the new ng14 FormBuilder, if you try to add a control with both arra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Mikastark |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width