{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1808","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1808/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1808/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1808/events","html_url":"https://github.com/Microsoft/TypeScript/issues/1808","id":55488265,"number":1808,"title":"Spec contradicts to itself in one of the examples with type guards","user":{"login":"zhuravlikjb","id":4499495,"avatar_url":"https://avatars.githubusercontent.com/u/4499495?v=3","gravatar_id":"","url":"https://api.github.com/users/zhuravlikjb","html_url":"https://github.com/zhuravlikjb","followers_url":"https://api.github.com/users/zhuravlikjb/followers","following_url":"https://api.github.com/users/zhuravlikjb/following{/other_user}","gists_url":"https://api.github.com/users/zhuravlikjb/gists{/gist_id}","starred_url":"https://api.github.com/users/zhuravlikjb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhuravlikjb/subscriptions","organizations_url":"https://api.github.com/users/zhuravlikjb/orgs","repos_url":"https://api.github.com/users/zhuravlikjb/repos","events_url":"https://api.github.com/users/zhuravlikjb/events{/privacy}","received_events_url":"https://api.github.com/users/zhuravlikjb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-26T14:31:36Z","updated_at":"2015-01-26T14:39:54Z","closed_at":null,"body":"In the [section about type guards](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#420-type-guards), the last example seems to be invalid:\r\n```javascript\r\nclass NamedItem {  \r\n    name: string;  \r\n}\r\n\r\nfunction getName(obj: any) {  \r\n    return obj instanceof NamedItem ? obj.name : \"unknown\";  \r\n}\r\n```\r\nIt is stated that `the inferred type of the 'getName' function is string`, but actually 'any' type won't be narrowed, according to the same spec, and compiler doesn't do that either:\r\n\r\n![getname](https://cloud.githubusercontent.com/assets/4499495/5901140/09a9c548-a581-11e4-9912-a5fb6831998a.png)\r\n\r\nA bug in the spec?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/71469820","html_url":"https://github.com/Microsoft/TypeScript/issues/1808#issuecomment-71469820","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/1808","id":71469820,"user":{"login":"ahejlsberg","id":4226954,"avatar_url":"https://avatars.githubusercontent.com/u/4226954?v=3","gravatar_id":"","url":"https://api.github.com/users/ahejlsberg","html_url":"https://github.com/ahejlsberg","followers_url":"https://api.github.com/users/ahejlsberg/followers","following_url":"https://api.github.com/users/ahejlsberg/following{/other_user}","gists_url":"https://api.github.com/users/ahejlsberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ahejlsberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahejlsberg/subscriptions","organizations_url":"https://api.github.com/users/ahejlsberg/orgs","repos_url":"https://api.github.com/users/ahejlsberg/repos","events_url":"https://api.github.com/users/ahejlsberg/events{/privacy}","received_events_url":"https://api.github.com/users/ahejlsberg/received_events","type":"User","site_admin":false},"created_at":"2015-01-26T14:39:54Z","updated_at":"2015-01-26T14:39:54Z","body":"Yes, that is a bug in the spec."}}