{"comment":{"url":"https://api.github.com/repos/sphereio/sphere-node-sdk/comments/18897152","html_url":"https://github.com/sphereio/sphere-node-sdk/commit/0a0d752c5c94b9f5dfcd8e64531c6640a6153d97#commitcomment-18897152","id":18897152,"user":{"login":"dferber90","id":1765075,"avatar_url":"https://avatars.githubusercontent.com/u/1765075?v=3","gravatar_id":"","url":"https://api.github.com/users/dferber90","html_url":"https://github.com/dferber90","followers_url":"https://api.github.com/users/dferber90/followers","following_url":"https://api.github.com/users/dferber90/following{/other_user}","gists_url":"https://api.github.com/users/dferber90/gists{/gist_id}","starred_url":"https://api.github.com/users/dferber90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dferber90/subscriptions","organizations_url":"https://api.github.com/users/dferber90/orgs","repos_url":"https://api.github.com/users/dferber90/repos","events_url":"https://api.github.com/users/dferber90/events{/privacy}","received_events_url":"https://api.github.com/users/dferber90/received_events","type":"User","site_admin":false},"position":11,"line":9,"path":"src/utils/create-reducer.js","commit_id":"0a0d752c5c94b9f5dfcd8e64531c6640a6153d97","created_at":"2016-09-05T08:01:54Z","updated_at":"2016-09-05T08:01:54Z","body":"Couldn't `initialState` and `state` be of different types? e.g. `initialState` is `undefined` but after the first action, `state` is an object? Do we need union types to express this?\r\n\r\nThis is what the code would look like then, meaning the result is either of `initalState`'s type, or of the previous state's type.\r\n```js\r\nexport default function createReducer<T, X> (\r\n  initialState: T,\r\n  actionHandlers\r\n) {\r\n  return (state: X, action) : T | X => {\r\n```\r\n\r\n- https://flowtype.org/docs/functions.html#overloading\r\n- https://flowtype.org/docs/union-intersection-types.html\r\n\r\n---\r\n\r\nAfter thinking about it a bit more, the current code is probably correct. In this case, the incoming type `T` should already be a union of `undefined` and the state shape. Seems correct as is.\r\n\r\n"}}
{"actor":{"display_login":"dferber90"}}