{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/1121","labels_url":"https://api.github.com/repos/facebook/flow/issues/1121/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/1121/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/1121/events","html_url":"https://github.com/facebook/flow/issues/1121","id":118289719,"number":1121,"title":"React.createElement interface could be more restrictive","user":{"login":"cprodescu","id":1377013,"avatar_url":"https://avatars.githubusercontent.com/u/1377013?v=3","gravatar_id":"","url":"https://api.github.com/users/cprodescu","html_url":"https://github.com/cprodescu","followers_url":"https://api.github.com/users/cprodescu/followers","following_url":"https://api.github.com/users/cprodescu/following{/other_user}","gists_url":"https://api.github.com/users/cprodescu/gists{/gist_id}","starred_url":"https://api.github.com/users/cprodescu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cprodescu/subscriptions","organizations_url":"https://api.github.com/users/cprodescu/orgs","repos_url":"https://api.github.com/users/cprodescu/repos","events_url":"https://api.github.com/users/cprodescu/events{/privacy}","received_events_url":"https://api.github.com/users/cprodescu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-22T21:32:18Z","updated_at":"2015-12-02T04:16:40Z","closed_at":null,"body":"The current interface for React.createElement is\r\n```\r\ndeclare function createElement<DefaultProps, Props, State, A: $Diff<Props, DefaultProps>>(\r\n    name: ReactClass<DefaultProps, Props, State>,\r\n    attributes: A,\r\n    children?: any\r\n  ): ReactElement<DefaultProps, Props, State>;\r\n```\r\n\r\nWhile this ensures all non-default props are passed as attributes, it does not restrict arbitrary props from being passed.\r\n\r\nI think the declaration for the attributes should be:\r\n```\r\nA: $Shape<Props> & $Diff<Props, DefaultProps>\r\n```\r\n\r\nI think making this more restrictive is beneficial as passing a prop to a class which does not expect is often a bug. For example, imagine a class which expected a prop minSize which was later refactored to receive minWidth and minHeight. If these have defaults, the bug would not be caught at component call-sites.\r\n\r\nOf course, I'm not sure this is a bug or by design.\r\n- Are there createElement attributes which are not component props? If that set is finite, we could still have `$Shape<GlobalAttributes & Props> & $Diff<Props, DefaultProps>`."},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/161176577","html_url":"https://github.com/facebook/flow/issues/1121#issuecomment-161176577","issue_url":"https://api.github.com/repos/facebook/flow/issues/1121","id":161176577,"user":{"login":"smirea","id":544097,"avatar_url":"https://avatars.githubusercontent.com/u/544097?v=3","gravatar_id":"","url":"https://api.github.com/users/smirea","html_url":"https://github.com/smirea","followers_url":"https://api.github.com/users/smirea/followers","following_url":"https://api.github.com/users/smirea/following{/other_user}","gists_url":"https://api.github.com/users/smirea/gists{/gist_id}","starred_url":"https://api.github.com/users/smirea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smirea/subscriptions","organizations_url":"https://api.github.com/users/smirea/orgs","repos_url":"https://api.github.com/users/smirea/repos","events_url":"https://api.github.com/users/smirea/events{/privacy}","received_events_url":"https://api.github.com/users/smirea/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T04:16:40Z","updated_at":"2015-12-02T04:16:40Z","body":"+1 this would be very useful and doesn't seem hard to implement"}}