{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/5291","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/5291/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/5291/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/5291/events","html_url":"https://github.com/facebook/flow/issues/5291","id":271976953,"number":5291,"title":"Flow can not decide which case to select when constant is imported.","user":{"login":"dmueller39","id":9422359,"avatar_url":"https://avatars0.githubusercontent.com/u/9422359?v=4","gravatar_id":"","url":"https://api.github.com/users/dmueller39","html_url":"https://github.com/dmueller39","followers_url":"https://api.github.com/users/dmueller39/followers","following_url":"https://api.github.com/users/dmueller39/following{/other_user}","gists_url":"https://api.github.com/users/dmueller39/gists{/gist_id}","starred_url":"https://api.github.com/users/dmueller39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmueller39/subscriptions","organizations_url":"https://api.github.com/users/dmueller39/orgs","repos_url":"https://api.github.com/users/dmueller39/repos","events_url":"https://api.github.com/users/dmueller39/events{/privacy}","received_events_url":"https://api.github.com/users/dmueller39/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-07T20:44:59Z","updated_at":"2017-11-07T20:53:11Z","closed_at":null,"author_association":"NONE","body":"Here is a demonstration of the error: \r\n\r\nexternally defined constant:\r\n```js\r\n// @flow\r\nexport const Foo:'foo' = 'foo';\r\n```\r\n\r\nimporting and using the constant will cause an error:\r\n```js\r\n// @flow\r\nimport { Foo } from './constants';\r\n\r\ntype Action = { type: typeof Foo, config: { } } | { type: 'bar'};\r\n\r\n/* expect error\r\nobject literal\r\nCould not decide which case to select\r\nunion type\r\n...\r\n*/\r\nconst action: Action = { type: Foo, config: { } }\r\n```\r\n\r\nIf its within the same file its fine:\r\n```js\r\n// @flow\r\n\r\nexport const Foo:'foo' = 'foo';\r\n\r\ntype Action = { type: typeof Foo, config: { } } | { type: 'bar'};\r\n\r\n/* works fine */\r\nconst action: Action = { type: Foo, config: { } }\r\n```\r\nIn theory there should be no difference between cases where a constant is imported and when it is defined within the file"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/342618488","html_url":"https://github.com/facebook/flow/issues/5291#issuecomment-342618488","issue_url":"https://api.github.com/repos/facebook/flow/issues/5291","id":342618488,"user":{"login":"bradennapier","id":15365418,"avatar_url":"https://avatars3.githubusercontent.com/u/15365418?v=4","gravatar_id":"","url":"https://api.github.com/users/bradennapier","html_url":"https://github.com/bradennapier","followers_url":"https://api.github.com/users/bradennapier/followers","following_url":"https://api.github.com/users/bradennapier/following{/other_user}","gists_url":"https://api.github.com/users/bradennapier/gists{/gist_id}","starred_url":"https://api.github.com/users/bradennapier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradennapier/subscriptions","organizations_url":"https://api.github.com/users/bradennapier/orgs","repos_url":"https://api.github.com/users/bradennapier/repos","events_url":"https://api.github.com/users/bradennapier/events{/privacy}","received_events_url":"https://api.github.com/users/bradennapier/received_events","type":"User","site_admin":false},"created_at":"2017-11-07T20:53:11Z","updated_at":"2017-11-07T20:53:11Z","author_association":"NONE","body":"When importing values like strings it will reduce it to `string` not `'foo'` - you probably want to use opaque types instead. "}}
{"actor":{"display_login":"bradennapier"}}