{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/2377","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/2377/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/2377/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/2377/events","html_url":"https://github.com/facebook/flow/issues/2377","id":174493592,"number":2377,"title":"Type check doesn't work for constants","user":{"login":"mhollweck","id":2960797,"avatar_url":"https://avatars0.githubusercontent.com/u/2960797?v=4","gravatar_id":"","url":"https://api.github.com/users/mhollweck","html_url":"https://github.com/mhollweck","followers_url":"https://api.github.com/users/mhollweck/followers","following_url":"https://api.github.com/users/mhollweck/following{/other_user}","gists_url":"https://api.github.com/users/mhollweck/gists{/gist_id}","starred_url":"https://api.github.com/users/mhollweck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhollweck/subscriptions","organizations_url":"https://api.github.com/users/mhollweck/orgs","repos_url":"https://api.github.com/users/mhollweck/repos","events_url":"https://api.github.com/users/mhollweck/events{/privacy}","received_events_url":"https://api.github.com/users/mhollweck/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-09-01T10:52:13Z","updated_at":"2018-03-13T10:11:04Z","closed_at":"2017-03-13T23:03:21Z","author_association":"NONE","body":"I have an issue with a flow check on a prop type:\n\n```\n// ButtonInputs.js\n\nexport const ButtonTypes = {\n  PRIMARY: 'primary',\n  PRIMARY_SPECIAL: 'primary-special',\n}\n\nexport type Button =\n  | ButtonTypes.PRIMARY\n  | ButtonTypes.PRIMARY_SPECIAL;\n\n// MyCustomButton.js\n\nimport type { Button } from 'ButtonInputs';\n\ntype Props = {\n  type: Button;\n}\n\n<MyCustomButton type=\"test\" /> // WORKS! (shouldn't work)\n```\n\nHowever, when changing the constants back to normal strings, the flow check works as expected.\n\n```\nexport type Button =\n  | 'primary'\n  | 'primary-special';\n```\n\nAny idea why this is the case? Is this a known bug?\n"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/372613462","html_url":"https://github.com/facebook/flow/issues/2377#issuecomment-372613462","issue_url":"https://api.github.com/repos/facebook/flow/issues/2377","id":372613462,"user":{"login":"ckitterl","id":1551727,"avatar_url":"https://avatars3.githubusercontent.com/u/1551727?v=4","gravatar_id":"","url":"https://api.github.com/users/ckitterl","html_url":"https://github.com/ckitterl","followers_url":"https://api.github.com/users/ckitterl/followers","following_url":"https://api.github.com/users/ckitterl/following{/other_user}","gists_url":"https://api.github.com/users/ckitterl/gists{/gist_id}","starred_url":"https://api.github.com/users/ckitterl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckitterl/subscriptions","organizations_url":"https://api.github.com/users/ckitterl/orgs","repos_url":"https://api.github.com/users/ckitterl/repos","events_url":"https://api.github.com/users/ckitterl/events{/privacy}","received_events_url":"https://api.github.com/users/ckitterl/received_events","type":"User","site_admin":false},"created_at":"2018-03-13T10:11:04Z","updated_at":"2018-03-13T10:11:04Z","author_association":"NONE","body":"Thanks to @fagerbua , I improved the code just like this\r\n```\r\n// @flow\r\n\r\nconst ButtonTypes:\r\n{\r\n    PRIMARY: 0,\r\n    SECONDARY: 1,\r\n    PRIMARY_SPECIAL: 2,\r\n} = {\r\n    PRIMARY: 0,\r\n    SECONDARY: 1,\r\n    PRIMARY_SPECIAL: 2,\r\n}\r\n\r\ntype Props = $Values<typeof ButtonTypes>;\r\n\r\nfunction show(buttonType: Props) {\r\n    console.log(buttonType);\r\n}\r\n\r\nshow(ButtonTypes.PRIMARY); // No Error\r\nshow(3); // This type is incompatible with the expected param type of number enum\r\n```"}}
{"actor":{"display_login":"ckitterl"}}