{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/6551","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/6551/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/6551/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/6551/events","html_url":"https://github.com/facebook/flow/issues/6551","id":337229168,"node_id":"MDU6SXNzdWUzMzcyMjkxNjg=","number":6551,"title":"Generic type T is inferred as T | any","user":{"login":"zoontek","id":1902323,"node_id":"MDQ6VXNlcjE5MDIzMjM=","avatar_url":"https://avatars2.githubusercontent.com/u/1902323?v=4","gravatar_id":"","url":"https://api.github.com/users/zoontek","html_url":"https://github.com/zoontek","followers_url":"https://api.github.com/users/zoontek/followers","following_url":"https://api.github.com/users/zoontek/following{/other_user}","gists_url":"https://api.github.com/users/zoontek/gists{/gist_id}","starred_url":"https://api.github.com/users/zoontek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoontek/subscriptions","organizations_url":"https://api.github.com/users/zoontek/orgs","repos_url":"https://api.github.com/users/zoontek/repos","events_url":"https://api.github.com/users/zoontek/events{/privacy}","received_events_url":"https://api.github.com/users/zoontek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-30T17:11:34Z","updated_at":"2018-06-30T17:11:34Z","closed_at":null,"author_association":"NONE","body":"Hello!\r\n\r\nI try to re-implement ReasonReact ReducerComponent using React + flow + switch exhaustiveness.\r\nBut when I use my render prop, flow infer my state param as `State | any` and I don't understand why.\r\n\r\n```js\r\ntype Props<S, A> = {|\r\n  initialState: S,\r\n  reducer: (state: S, action: A) => S,\r\n  render: ({|\r\n    state: S,\r\n    send: (action: A) => void,\r\n  |}) => React$Node,\r\n|};\r\n\r\nexport class ReducerComponent<\r\n  S: {},\r\n  A: { type: $Subtype<string> },\r\n> extends React.Component<Props<S, A>, S> {\r\n  state: S;\r\n\r\n  constructor(props: Props<S, A>) {\r\n    super(props);\r\n    this.state = props.initialState;\r\n  }\r\n\r\n  render() {\r\n    return this.props.render({\r\n      state: this.state,\r\n      send: action => this.setState(state => this.props.reducer(state, action)),\r\n    });\r\n  }\r\n}\r\n\r\n// usage\r\n\r\ntype State = {| count: number |};\r\ntype Action = {| type: 'INCREMENT' |};\r\n\r\nclass Counter extends React.Component<{}> {\r\n  initialState: State = { count: 0 };\r\n\r\n  // state arg if of type {|count: number|} | State | any\r\n  reducer = (state, action: Action) => state;\r\n\r\n  render() {\r\n    return (\r\n      <ReducerComponent\r\n        initialState={this.initialState}\r\n        reducer={this.reducer}\r\n        // state param if of type {|count: number|} | any\r\n        render={({ state, send }) => <div />}\r\n      />\r\n    );\r\n  }\r\n}\r\n```\r\n\r\nDemo is available here: \r\n\r\nhttps://flow.org/try/#0PTAEAEDMBsHsHcBQiCWBbADrATgF1AEoCmAhgMb6TaxqgDk2pFdA3MrgJ4ZGgAK1GAM4AeAMoAaUAEEAfKAC8oAN4AfRKFAoAdilwoS0UbhK4iALlAT1oRgBMArmSLYLACkHHTFiaHJ7YWhZSAJQKclYajFq2zm6q1hoeJuaW4gmggkTRbn4oAUGh8nIAbrAotmkaKgC+hXLEfgAkAHKwMWk1bIhEAB5YeKBk0CSCgoREDk7YAMI0WFpZuMLWohZK1ZXSa6Cc3BaNovYARrtEwh7Y2gDmchuIcr2m0WMNFAB0s5gBi8L8sEJiSSySSiORKaxJLyWLoaMgBC6OXA4VwYASCCx-AE+WShcEaRL2bjYFFo4JsfE7AAWKEEb0hPEUqP+tO0un0hk8RHJoGqyEiWRixNx6UYuHs2C0VJpbyZQjeUUFrjxFIynIsuGptPpmwpmWyvgoeUlRSlWqIuCMyXcnLCpplaPlE0czmtyUkuQCwWCOp5ZOsvN5iBAoHsghIVyIyEQp0sNsUqkGsHsWlwFi09jQR2coE60a4PCkhoCCmUKh2+YsdAAks1pgQAKIAWXrzQAKnQc9UukMRmNZsnTNhQI8BS8mLgPnNvinhOswdZWXoDJaoSuGcpEwOLAAGHkw0DB+m+bBXTSQUCwc8x1RwregdOZ5w1HOx5IvkhaDjWOzOoeKV2mO6RaBNIwF1KqyT7gqLrChSoripKrjpBowjEJMzifPMizIfii7smu8hKBq0p4cunK8iq+I-lMhHEbS1HOBRlEHmAR4YCQ2AkLQKDnpe5bcKWt4pmmGZZtgz5lh+X7MTYArOIRSoQYBGQCr6trCLYKDFAeMhMRSwAyOkfoaAGiBAA"}}
{"actor":{"display_login":"zoontek"}}