{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/2368","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/2368/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/2368/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/2368/events","html_url":"https://github.com/facebook/flow/issues/2368","id":174027482,"number":2368,"title":"Dynamic object keys question","user":{"login":"chrisblossom","id":1595871,"avatar_url":"https://avatars.githubusercontent.com/u/1595871?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisblossom","html_url":"https://github.com/chrisblossom","followers_url":"https://api.github.com/users/chrisblossom/followers","following_url":"https://api.github.com/users/chrisblossom/following{/other_user}","gists_url":"https://api.github.com/users/chrisblossom/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisblossom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisblossom/subscriptions","organizations_url":"https://api.github.com/users/chrisblossom/orgs","repos_url":"https://api.github.com/users/chrisblossom/repos","events_url":"https://api.github.com/users/chrisblossom/events{/privacy}","received_events_url":"https://api.github.com/users/chrisblossom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-30T14:02:44Z","updated_at":"2016-08-30T14:02:44Z","closed_at":null,"body":"I am trying to figure out the correct way to declare an object that has both static and dynamic properties. Am I doing this correctly? Or is there a different / better way?\r\n\r\n```ts\r\ntype ObjectTypes = {\r\n  exists: string;\r\n  sometimesExists?: string;\r\n\r\n  // If any other keys exist, they should follow this pattern:\r\n  [field: string]: {\r\n    some: number;\r\n  };\r\n};\r\n\r\nconst passes_flow1 = (): ObjectTypes => {\r\n  return {\r\n    exists: 'some string',\r\n    other: {\r\n      some: 123,\r\n    },\r\n  };\r\n};\r\n\r\nconst passes_flow2 = (): ObjectTypes => {\r\n  return {\r\n    exists: 'some string',\r\n  };\r\n};\r\n\r\nconst fails_flow1 = (): ObjectTypes => {\r\n  return {\r\n    exists: 'some string',\r\n    sometimesExists: 'other string',\r\n    other: {\r\n      some: 'should be a number',\r\n    },\r\n  };\r\n};\r\n\r\nconsole.log(passes_flow1());\r\nconsole.log(passes_flow2());\r\nconsole.log(fails_flow1());\r\n```\r\n\r\n(Linking issue https://github.com/gcanti/babel-plugin-tcomb/issues/100)"}}
{"actor":{"display_login":"chrisblossom"}}