{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/11425","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/11425/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/11425/comments","events_url":"https://api.github.com/repos/angular/angular/issues/11425/events","html_url":"https://github.com/angular/angular/issues/11425","id":175630853,"number":11425,"title":"Improve how AoT compiler casts to boolean","user":{"login":"RoxKilly","id":12346501,"avatar_url":"https://avatars.githubusercontent.com/u/12346501?v=3","gravatar_id":"","url":"https://api.github.com/users/RoxKilly","html_url":"https://github.com/RoxKilly","followers_url":"https://api.github.com/users/RoxKilly/followers","following_url":"https://api.github.com/users/RoxKilly/following{/other_user}","gists_url":"https://api.github.com/users/RoxKilly/gists{/gist_id}","starred_url":"https://api.github.com/users/RoxKilly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoxKilly/subscriptions","organizations_url":"https://api.github.com/users/RoxKilly/orgs","repos_url":"https://api.github.com/users/RoxKilly/repos","events_url":"https://api.github.com/users/RoxKilly/events{/privacy}","received_events_url":"https://api.github.com/users/RoxKilly/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular/labels/hotlist:%20error%20messages","name":"hotlist: error messages","color":"d4c5f9"},{"url":"https://api.github.com/repos/angular/angular/labels/need:%20repro","name":"need: repro","color":"006b75"},{"url":"https://api.github.com/repos/angular/angular/labels/offline_compile","name":"offline_compile","color":"c7def8"},{"url":"https://api.github.com/repos/angular/angular/labels/type:%20bug","name":"type: bug","color":"EEEEEE"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-09-07T23:31:06Z","updated_at":"2016-09-11T11:07:07Z","closed_at":"2016-09-08T02:57:10Z","body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report => search github for a similar issue or PR before submitting\r\n```\r\n\r\n**Current behavior**\r\n\r\nDuring `ngc` compilation, I get several errors of the type:\r\n```\r\nType 'IDrillActive' is not assignable to type 'boolean'.\r\n```\r\n\r\nAs the compiler parses auto-generated code:\r\n```\r\nconst currVal_0:boolean = (!this.context.store.appState.loading && this.context.drill);\r\n```\r\n\r\nThese errors from `.ngfactory.ts` files clutter the IDE and make it tougher to spot errors in my own code.\r\n\r\n**Expected behavior**\r\n\r\nI think it would be better to properly cast expressions to booleans.  For instance the line above could be re-factored to:\r\n```\r\nconst currVal_0:boolean = !!(!this.context.store.appState.loading && this.context.drill);\r\n```\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\r\nTo reduce compiler errors generated by `.ngfactory.ts` files\r\n\r\n**Please tell us about your environment:**\r\n\r\n* **Angular version:** 2.0.0-rc.6\r\n \r\n* **Browser:** [all] \r\n \r\n* **Language:** [TypeScript 2.0.2]\r\n \r\n* **Node (for AoT issues):** `node --version` =   4.5.0\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/246174674","html_url":"https://github.com/angular/angular/issues/11425#issuecomment-246174674","issue_url":"https://api.github.com/repos/angular/angular/issues/11425","id":246174674,"user":{"login":"RoxKilly","id":12346501,"avatar_url":"https://avatars.githubusercontent.com/u/12346501?v=3","gravatar_id":"","url":"https://api.github.com/users/RoxKilly","html_url":"https://github.com/RoxKilly","followers_url":"https://api.github.com/users/RoxKilly/followers","following_url":"https://api.github.com/users/RoxKilly/following{/other_user}","gists_url":"https://api.github.com/users/RoxKilly/gists{/gist_id}","starred_url":"https://api.github.com/users/RoxKilly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoxKilly/subscriptions","organizations_url":"https://api.github.com/users/RoxKilly/orgs","repos_url":"https://api.github.com/users/RoxKilly/repos","events_url":"https://api.github.com/users/RoxKilly/events{/privacy}","received_events_url":"https://api.github.com/users/RoxKilly/received_events","type":"User","site_admin":false},"created_at":"2016-09-11T11:07:07Z","updated_at":"2016-09-11T11:07:07Z","body":"@vvakame  the problem is with our code, not Angular.\r\n```\r\n!loggedIn && loginURL\r\n```\r\nThis resolves to a string because the 2nd operand is a string.  If you don't want to see these errors, you need to adjust your conditional statements to return booleans, not just truthey values.  For instance you could do:\r\n```\r\nloginURL && !loggedIn\r\n```\r\nTypescript resolves this to a boolean (the type of the last operand) so you won't see the error.\r\n\r\nAlternatively, you could force your non-booleans into booleans with the `!!` prefix:\r\n```\r\n!loggedIn && !!loginURL\r\n```\r\n"}}
{"actor":{"display_login":"RoxKilly"}}