{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/627","labels_url":"https://api.github.com/repos/facebook/flow/issues/627/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/627/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/627/events","html_url":"https://github.com/facebook/flow/issues/627","id":94777503,"number":627,"title":"Syntactic sugar for enum types","user":{"login":"danvk","id":98301,"avatar_url":"https://avatars.githubusercontent.com/u/98301?v=3","gravatar_id":"","url":"https://api.github.com/users/danvk","html_url":"https://github.com/danvk","followers_url":"https://api.github.com/users/danvk/followers","following_url":"https://api.github.com/users/danvk/following{/other_user}","gists_url":"https://api.github.com/users/danvk/gists{/gist_id}","starred_url":"https://api.github.com/users/danvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danvk/subscriptions","organizations_url":"https://api.github.com/users/danvk/orgs","repos_url":"https://api.github.com/users/danvk/repos","events_url":"https://api.github.com/users/danvk/events{/privacy}","received_events_url":"https://api.github.com/users/danvk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/flow/labels/documentation","name":"documentation","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-13T18:07:01Z","updated_at":"2015-07-24T20:23:02Z","closed_at":null,"body":"TypeScript [has this][1]\r\n\r\n```javascript\r\nenum Color {Red = 1, Green = 2, Blue = 4};\r\nvar c: Color = Color.Green;\r\n```\r\n\r\nI'd prefer something that looked more like object literal syntax, for simpler translation to ES5:\r\n\r\n```javascript\r\nenum var Color = {Red: 1, Green: 2, Blue: 4};\r\nvar c: Color = Color.Green;\r\n```\r\n\r\nIt looks like you can get at this using [disjoint unions][2]:\r\n\r\n```javascript\r\ntype Foo = 1 | 2;\r\n\r\nvar x: Foo = 1;  // OK\r\nvar y: Foo = 3;  // Error: number This type is incompatible with union type\r\n```\r\n\r\nSo this may just be a request for a more standard syntax, or just a call out that this is how you do enumerations in FlowType.\r\n\r\n[1]: http://www.typescriptlang.org/Handbook#basic-types-enum\r\n[2]: http://flowtype.org/blog/2015/07/03/Disjoint-Unions.html"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/124709630","html_url":"https://github.com/facebook/flow/issues/627#issuecomment-124709630","issue_url":"https://api.github.com/repos/facebook/flow/issues/627","id":124709630,"user":{"login":"jeffmo","id":498293,"avatar_url":"https://avatars.githubusercontent.com/u/498293?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffmo","html_url":"https://github.com/jeffmo","followers_url":"https://api.github.com/users/jeffmo/followers","following_url":"https://api.github.com/users/jeffmo/following{/other_user}","gists_url":"https://api.github.com/users/jeffmo/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmo/subscriptions","organizations_url":"https://api.github.com/users/jeffmo/orgs","repos_url":"https://api.github.com/users/jeffmo/repos","events_url":"https://api.github.com/users/jeffmo/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmo/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T20:23:02Z","updated_at":"2015-07-24T20:23:02Z","body":"Indeed disjoint unions would be the recommendation for enums (and I'd say typically string literals will be more descriptive than numbers).\r\n\r\nKeeping this open to track documentation around this as suggested"}}