{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4432","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4432/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4432/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4432/events","html_url":"https://github.com/Microsoft/TypeScript/issues/4432","id":102911849,"number":4432,"title":"User-defined type guards don't work for all types","user":{"login":"jonathandturner","id":547158,"avatar_url":"https://avatars.githubusercontent.com/u/547158?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathandturner","html_url":"https://github.com/jonathandturner","followers_url":"https://api.github.com/users/jonathandturner/followers","following_url":"https://api.github.com/users/jonathandturner/following{/other_user}","gists_url":"https://api.github.com/users/jonathandturner/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathandturner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathandturner/subscriptions","organizations_url":"https://api.github.com/users/jonathandturner/orgs","repos_url":"https://api.github.com/users/jonathandturner/repos","events_url":"https://api.github.com/users/jonathandturner/events{/privacy}","received_events_url":"https://api.github.com/users/jonathandturner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Breaking%20Change","name":"Breaking Change","color":"eb6420"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"DanielRosenwasser","id":972891,"avatar_url":"https://avatars.githubusercontent.com/u/972891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielRosenwasser","html_url":"https://github.com/DanielRosenwasser","followers_url":"https://api.github.com/users/DanielRosenwasser/followers","following_url":"https://api.github.com/users/DanielRosenwasser/following{/other_user}","gists_url":"https://api.github.com/users/DanielRosenwasser/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielRosenwasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielRosenwasser/subscriptions","organizations_url":"https://api.github.com/users/DanielRosenwasser/orgs","repos_url":"https://api.github.com/users/DanielRosenwasser/repos","events_url":"https://api.github.com/users/DanielRosenwasser/events{/privacy}","received_events_url":"https://api.github.com/users/DanielRosenwasser/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/11","html_url":"https://github.com/Microsoft/TypeScript/milestones/TypeScript%201.7","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/11/labels","id":1189604,"number":11,"title":"TypeScript 1.7","description":"","creator":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"open_issues":111,"closed_issues":8,"state":"open","created_at":"2015-07-01T19:21:45Z","updated_at":"2015-09-10T22:38:56Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2015-08-24T23:19:24Z","updated_at":"2015-09-11T03:55:24Z","closed_at":null,"body":"If the user defines a type guard for a boolean, as in this example:\r\n\r\n```TypeScript\r\nfunction isBool(a: any): a is boolean {\r\n    return (typeof a === \"boolean\");\r\n}\r\n\r\nfunction bob() {\r\n    var z;\r\n\r\n    if (isBool(z)) {\r\n        z; // type of z is still 'any'\r\n    }\r\n}\r\n```\r\n\r\n...then z is not properly refined to 'boolean'.  It stays 'any'.  I think the expected behavior here is for the type guard to refine to boolean inside of the if check."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/139446467","html_url":"https://github.com/Microsoft/TypeScript/issues/4432#issuecomment-139446467","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4432","id":139446467,"user":{"login":"dsherret","id":1609021,"avatar_url":"https://avatars.githubusercontent.com/u/1609021?v=3","gravatar_id":"","url":"https://api.github.com/users/dsherret","html_url":"https://github.com/dsherret","followers_url":"https://api.github.com/users/dsherret/followers","following_url":"https://api.github.com/users/dsherret/following{/other_user}","gists_url":"https://api.github.com/users/dsherret/gists{/gist_id}","starred_url":"https://api.github.com/users/dsherret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsherret/subscriptions","organizations_url":"https://api.github.com/users/dsherret/orgs","repos_url":"https://api.github.com/users/dsherret/repos","events_url":"https://api.github.com/users/dsherret/events{/privacy}","received_events_url":"https://api.github.com/users/dsherret/received_events","type":"User","site_admin":false},"created_at":"2015-09-11T03:55:24Z","updated_at":"2015-09-11T03:55:24Z","body":"+1 for narrowing `any`. Good decision."}}