{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/18991","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/18991/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/18991/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/18991/events","html_url":"https://github.com/Microsoft/TypeScript/issues/18991","id":263416227,"number":18991,"title":"All but type T check and assignment of T is not working","user":{"login":"tinganho","id":1324476,"avatar_url":"https://avatars3.githubusercontent.com/u/1324476?v=4","gravatar_id":"","url":"https://api.github.com/users/tinganho","html_url":"https://github.com/tinganho","followers_url":"https://api.github.com/users/tinganho/followers","following_url":"https://api.github.com/users/tinganho/following{/other_user}","gists_url":"https://api.github.com/users/tinganho/gists{/gist_id}","starred_url":"https://api.github.com/users/tinganho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinganho/subscriptions","organizations_url":"https://api.github.com/users/tinganho/orgs","repos_url":"https://api.github.com/users/tinganho/repos","events_url":"https://api.github.com/users/tinganho/events{/privacy}","received_events_url":"https://api.github.com/users/tinganho/received_events","type":"User","site_admin":false},"labels":[{"id":371615203,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Working%20as%20Intended","name":"Working as Intended","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-06T11:31:53Z","updated_at":"2017-10-06T18:45:18Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!-- BUGS: Please use this template. -->\r\n<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:**  2.4.0 / nightly (2.5.0-dev.201xxxxx)\r\n\r\n**Code**\r\n\r\n```ts\r\n\r\ninterface A {\r\n    a: string;\r\n}\r\n\r\ninterface B {\r\n    b: string;\r\n}\r\n\r\nfunction isA(x: any): x is A {\r\n    return !!x.a;\r\n} \r\n\r\ndeclare let anull: A | null;\r\nif (anull == null) {\r\n    anull = { a: ' ' } as A;\r\n} \r\nanull.a; // No error because it's A\r\n\r\ndeclare let ab: A | B;\r\nif (!isA(ab)) {\r\n    ab = { b: ' ' } as B;\r\n}\r\nab.b // Error b does not exists on type A | B\r\n\r\n```\r\n\r\n**Expected behavior:**\r\n`ab` to be of type `B`\r\n\r\n**Actual behavior:**\r\n`ab` to be of type ` A | B`\r\n\r\nhttp://www.typescriptlang.org/play/#src=%0Ainterface%20A%20%7B%0A%20%20%20%20a%3A%20string%3B%0A%7D%0A%0Ainterface%20B%20%7B%0A%20%20%20%20b%3A%20string%3B%0A%7D%0A%0Afunction%20isA(x%3A%20any)%3A%20x%20is%20A%20%7B%0A%20%20%20%20return%20!!x.a%3B%0A%7D%20%0A%0Adeclare%20let%20anull%3A%20A%20%7C%20null%3B%0Aif%20(anull%20%3D%3D%20null)%20%7B%0A%20%20%20%20anull%20%3D%20%7B%20a%3A%20'%20'%20%7D%20as%20A%3B%0A%7D%20%0Aanull.a%3B%20%2F%2F%20No%20error%0A%0Adeclare%20let%20ab%3A%20A%20%7C%20B%3B%0Aif%20(!isA(ab))%20%7B%0A%20%20%20%20ab%20%3D%20%7B%20b%3A%20'%20'%20%7D%20as%20B%3B%0A%7D%0Aab.b%20%2F%2F%20Error%20b%20does%20not%20exists%20on%20type%20A%20%7C%C2%A0B%0A\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/334838666","html_url":"https://github.com/Microsoft/TypeScript/issues/18991#issuecomment-334838666","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/18991","id":334838666,"user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars3.githubusercontent.com/u/6685088?v=4","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"created_at":"2017-10-06T18:45:18Z","updated_at":"2017-10-06T18:45:18Z","author_association":"MEMBER","body":"The type `A | AB` is effectively the same as `A` because we remove subtypes from unions when they have a corresponding supertype in the same union."}}
{"actor":{"display_login":"RyanCavanaugh"}}