{"action":"opened","number":32541,"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/32541","id":315215152,"node_id":"MDExOlB1bGxSZXF1ZXN0MzE1MjE1MTUy","html_url":"https://github.com/angular/angular/pull/32541","diff_url":"https://github.com/angular/angular/pull/32541.diff","patch_url":"https://github.com/angular/angular/pull/32541.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/32541","number":32541,"state":"open","locked":false,"title":"refactor(forms): use a type guard to get rid of casts","user":{"login":"lazarljubenovic","id":7661457,"node_id":"MDQ6VXNlcjc2NjE0NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/7661457?v=4","gravatar_id":"","url":"https://api.github.com/users/lazarljubenovic","html_url":"https://github.com/lazarljubenovic","followers_url":"https://api.github.com/users/lazarljubenovic/followers","following_url":"https://api.github.com/users/lazarljubenovic/following{/other_user}","gists_url":"https://api.github.com/users/lazarljubenovic/gists{/gist_id}","starred_url":"https://api.github.com/users/lazarljubenovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazarljubenovic/subscriptions","organizations_url":"https://api.github.com/users/lazarljubenovic/orgs","repos_url":"https://api.github.com/users/lazarljubenovic/repos","events_url":"https://api.github.com/users/lazarljubenovic/events{/privacy}","received_events_url":"https://api.github.com/users/lazarljubenovic/received_events","type":"User","site_admin":false},"body":"## PR Checklist\r\nPlease check if your PR fulfills the following requirements:\r\n\r\n- [x] The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit\r\n- [ ] Tests for the changes have been added (for bug fixes / features)\r\n- [ ] Docs have been added / updated (for bug fixes / features)\r\n\r\n\r\n## PR Type\r\nWhat kind of change does this PR introduce?\r\n\r\n<!-- Please check the one that applies to this PR using \"x\". -->\r\n\r\n- [ ] Bugfix\r\n- [ ] Feature\r\n- [ ] Code style update (formatting, local variables)\r\n- [x] Refactoring (no functional changes, no api changes)\r\n- [ ] Build related changes\r\n- [ ] CI related changes\r\n- [ ] Documentation content changes\r\n- [ ] angular.io application / infrastructure changes\r\n- [ ] Other... Please describe:\r\n\r\n\r\n## What is the current behavior?\r\n<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->\r\n\r\nNot utilizing TypeScript's features which the code would benefit from.\r\n\r\nIssue Number: N/A\r\n\r\n\r\n## What is the new behavior?\r\n\r\nWhen we use a guard, TypeScript infers the type in `if`s correctly. Thus, we can remove this mess of casts and parenthesis:\r\n\r\n```\r\n  const validator =\r\n      (isOptionsObj(validatorOrOpts) ? (validatorOrOpts as AbstractControlOptions).validators :\r\n                                       validatorOrOpts) as ValidatorFn |\r\n      ValidatorFn[] | null;\r\n```\r\n\r\nand simply write:\r\n\r\n```\r\n  const validator = isOptionsObj(validatorOrOpts) ? validatorOrOpts.validators : validatorOrOpts;\r\n```\r\n\r\nAll this by simply changing the return type of `isOptionsObj` from `boolean` to `validatorOrOpts is AbstractControlOptions`.\r\n\r\n## Does this PR introduce a breaking change?\r\n\r\n- [ ] Yes\r\n- [x] No\r\n\r\n\r\n<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->\r\n\r\n\r\n## Other information\r\n\r\nThis has nothing to do with a popular request to strongly type the forms. It's just internal refactoring.","created_at":"2019-09-07T18:18:30Z","updated_at":"2019-09-07T18:18:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"fw-forms","id":3050899,"node_id":"MDQ6VGVhbTMwNTA4OTk=","slug":"fw-forms","description":"","privacy":"closed","url":"https://api.github.com/teams/3050899","html_url":"https://github.com/orgs/angular/teams/fw-forms","members_url":"https://api.github.com/teams/3050899/members{/member}","repositories_url":"https://api.github.com/teams/3050899/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/32541/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/32541/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/32541/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/58a09b8fc2f072de364f82da92c1d2339c72ca33","head":{"label":"lazarljubenovic:refactor-type-guards","ref":"refactor-type-guards","sha":"58a09b8fc2f072de364f82da92c1d2339c72ca33","user":{"login":"lazarljubenovic","id":7661457,"node_id":"MDQ6VXNlcjc2NjE0NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/7661457?v=4","gravatar_id":"","url":"https://api.github.com/users/lazarljubenovic","html_url":"https://github.com/lazarljubenovic","followers_url":"https://api.github.com/users/lazarljubenovic/followers","following_url":"https://api.github.com/users/lazarljubenovic/following{/other_user}","gists_url":"https://api.github.com/users/lazarljubenovic/gists{/gist_id}","starred_url":"https://api.github.com/users/lazarljubenovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazarljubenovic/subscriptions","organizations_url":"https://api.github.com/users/lazarljubenovic/orgs","repos_url":"https://api.github.com/users/lazarljubenovic/repos","events_url":"https://api.github.com/users/lazarljubenovic/events{/privacy}","received_events_url":"https://api.github.com/users/lazarljubenovic/received_events","type":"User","site_admin":false},"repo":{"id":106219098,"node_id":"MDEwOlJlcG9zaXRvcnkxMDYyMTkwOTg=","name":"angular","full_name":"lazarljubenovic/angular","private":false,"owner":{"login":"lazarljubenovic","id":7661457,"node_id":"MDQ6VXNlcjc2NjE0NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/7661457?v=4","gravatar_id":"","url":"https://api.github.com/users/lazarljubenovic","html_url":"https://github.com/lazarljubenovic","followers_url":"https://api.github.com/users/lazarljubenovic/followers","following_url":"https://api.github.com/users/lazarljubenovic/following{/other_user}","gists_url":"https://api.github.com/users/lazarljubenovic/gists{/gist_id}","starred_url":"https://api.github.com/users/lazarljubenovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazarljubenovic/subscriptions","organizations_url":"https://api.github.com/users/lazarljubenovic/orgs","repos_url":"https://api.github.com/users/lazarljubenovic/repos","events_url":"https://api.github.com/users/lazarljubenovic/events{/privacy}","received_events_url":"https://api.github.com/users/lazarljubenovic/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lazarljubenovic/angular","description":"One framework. Mobile & desktop.","fork":true,"url":"https://api.github.com/repos/lazarljubenovic/angular","forks_url":"https://api.github.com/repos/lazarljubenovic/angular/forks","keys_url":"https://api.github.com/repos/lazarljubenovic/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lazarljubenovic/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lazarljubenovic/angular/teams","hooks_url":"https://api.github.com/repos/lazarljubenovic/angular/hooks","issue_events_url":"https://api.github.com/repos/lazarljubenovic/angular/issues/events{/number}","events_url":"https://api.github.com/repos/lazarljubenovic/angular/events","assignees_url":"https://api.github.com/repos/lazarljubenovic/angular/assignees{/user}","branches_url":"https://api.github.com/repos/lazarljubenovic/angular/branches{/branch}","tags_url":"https://api.github.com/repos/lazarljubenovic/angular/tags","blobs_url":"https://api.github.com/repos/lazarljubenovic/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lazarljubenovic/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lazarljubenovic/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/lazarljubenovic/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lazarljubenovic/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/lazarljubenovic/angular/languages","stargazers_url":"https://api.github.com/repos/lazarljubenovic/angular/stargazers","contributors_url":"https://api.github.com/repos/lazarljubenovic/angular/contributors","subscribers_url":"https://api.github.com/repos/lazarljubenovic/angular/subscribers","subscription_url":"https://api.github.com/repos/lazarljubenovic/angular/subscription","commits_url":"https://api.github.com/repos/lazarljubenovic/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/lazarljubenovic/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/lazarljubenovic/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/lazarljubenovic/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/lazarljubenovic/angular/contents/{+path}","compare_url":"https://api.github.com/repos/lazarljubenovic/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lazarljubenovic/angular/merges","archive_url":"https://api.github.com/repos/lazarljubenovic/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lazarljubenovic/angular/downloads","issues_url":"https://api.github.com/repos/lazarljubenovic/angular/issues{/number}","pulls_url":"https://api.github.com/repos/lazarljubenovic/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/lazarljubenovic/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/lazarljubenovic/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lazarljubenovic/angular/labels{/name}","releases_url":"https://api.github.com/repos/lazarljubenovic/angular/releases{/id}","deployments_url":"https://api.github.com/repos/lazarljubenovic/angular/deployments","created_at":"2017-10-09T00:05:42Z","updated_at":"2017-10-09T18:05:40Z","pushed_at":"2019-09-07T18:13:44Z","git_url":"git://github.com/lazarljubenovic/angular.git","ssh_url":"git@github.com:lazarljubenovic/angular.git","clone_url":"https://github.com/lazarljubenovic/angular.git","svn_url":"https://github.com/lazarljubenovic/angular","homepage":"https://angular.io","size":116050,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"df5924abd0c4efe87e2fd189739e565346276b91","user":{"login":"angular","id":139426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzOTQyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/139426?v=4","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"node_id":"MDEwOlJlcG9zaXRvcnkyNDE5NTMzOQ==","name":"angular","full_name":"angular/angular","private":false,"owner":{"login":"angular","id":139426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzOTQyNg==","avatar_url":"https://avatars3.githubusercontent.com/u/139426?v=4","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/angular/angular","description":"One framework. Mobile & desktop.","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","deployments_url":"https://api.github.com/repos/angular/angular/deployments","created_at":"2014-09-18T16:12:01Z","updated_at":"2019-09-07T18:12:03Z","pushed_at":"2019-09-07T17:41:19Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":"https://angular.io","size":121669,"stargazers_count":51176,"watchers_count":51176,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14236,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":3118,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14236,"open_issues":3118,"watchers":51176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/32541"},"html":{"href":"https://github.com/angular/angular/pull/32541"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/32541"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/32541/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/32541/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/32541/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/58a09b8fc2f072de364f82da92c1d2339c72ca33"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":6,"deletions":12,"changed_files":1}}
{"actor":{"display_login":"lazarljubenovic"}}