{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/1664","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/1664/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/1664/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/1664/events","html_url":"https://github.com/facebook/flow/issues/1664","id":148420077,"number":1664,"title":"tagged unions ","user":{"login":"coot","id":698209,"avatar_url":"https://avatars.githubusercontent.com/u/698209?v=3","gravatar_id":"","url":"https://api.github.com/users/coot","html_url":"https://github.com/coot","followers_url":"https://api.github.com/users/coot/followers","following_url":"https://api.github.com/users/coot/following{/other_user}","gists_url":"https://api.github.com/users/coot/gists{/gist_id}","starred_url":"https://api.github.com/users/coot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coot/subscriptions","organizations_url":"https://api.github.com/users/coot/orgs","repos_url":"https://api.github.com/users/coot/repos","events_url":"https://api.github.com/users/coot/events{/privacy}","received_events_url":"https://api.github.com/users/coot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-14T16:44:18Z","updated_at":"2016-04-18T03:39:56Z","closed_at":null,"body":"The following code should type check while it does not:\r\n```\r\n/* @flow */\r\n\r\ndeclare interface DataBase {\r\n  id: string,\r\n  name: string,\r\n};\r\n\r\ndeclare interface UserData extends DataBase {\r\n  kind: \"user\",\r\n}\r\n\r\ndeclare interface SystemData extends DataBase {\r\n  kind: \"system\",\r\n}\r\n\r\ndeclare type Data = UserData | SystemData;\r\n\r\nconst data: Data = {\r\n  id: \"\",\r\n  name: \"\",\r\n  kind: \"system\",\r\n}\r\n\r\nif (data.kind == \"system\") {\r\n  let system: SystemData = data;\r\n}\r\n```\r\n\r\nThis fails to typecheck with the following error (using flow v0.23.0):\r\n```\r\n 15:   kind: \"system\",\r\n             ^^^^^^^^ string literal `system`. Expected string literal `user`, got `system` instead\r\n 11:   kind: \"user\",\r\n             ^^^^^^ string literal `user`\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/211177007","html_url":"https://github.com/facebook/flow/issues/1664#issuecomment-211177007","issue_url":"https://api.github.com/repos/facebook/flow/issues/1664","id":211177007,"user":{"login":"7ynk3r","id":6763798,"avatar_url":"https://avatars.githubusercontent.com/u/6763798?v=3","gravatar_id":"","url":"https://api.github.com/users/7ynk3r","html_url":"https://github.com/7ynk3r","followers_url":"https://api.github.com/users/7ynk3r/followers","following_url":"https://api.github.com/users/7ynk3r/following{/other_user}","gists_url":"https://api.github.com/users/7ynk3r/gists{/gist_id}","starred_url":"https://api.github.com/users/7ynk3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/7ynk3r/subscriptions","organizations_url":"https://api.github.com/users/7ynk3r/orgs","repos_url":"https://api.github.com/users/7ynk3r/repos","events_url":"https://api.github.com/users/7ynk3r/events{/privacy}","received_events_url":"https://api.github.com/users/7ynk3r/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T03:39:56Z","updated_at":"2016-04-18T03:39:56Z","body":"Same here. For some reason is making an intersection while reading the properties. \r\n\r\n    // @flow\r\n\r\n    export type Action =\r\n        { type: 'A', a: string }\r\n      | { type: 'B', b: string }\r\n      ;\r\n\r\n    const a0: Action = {type: 'A', a:'a'}\r\n    const b0: Action = {type: 'B', b:'b'}\r\n    const c0: Action = {type: 'A', b:'b'} // error: this is right\r\n    const d0: Action = {type: 'B', a:'a'} // error: this is right\r\n\r\n\r\n    console.log(a0.a); // error: this is NOT right!\r\n    const {type, a} = a0; // error: this is NOT right!\r\n\r\n    console.log(b0.b); // error: this is NOT right!\r\n    const {type, b} = b0; // error: this is NOT right!\r\n"}}