{"action":"opened","issue":{"url":"https://api.github.com/repos/flowtype/flow-typed/issues/469","repository_url":"https://api.github.com/repos/flowtype/flow-typed","labels_url":"https://api.github.com/repos/flowtype/flow-typed/issues/469/labels{/name}","comments_url":"https://api.github.com/repos/flowtype/flow-typed/issues/469/comments","events_url":"https://api.github.com/repos/flowtype/flow-typed/issues/469/events","html_url":"https://github.com/flowtype/flow-typed/issues/469","id":190634891,"number":469,"title":"redux-saga: Support calling normal function for \"call\" effect","user":{"login":"kuy","id":151614,"avatar_url":"https://avatars.githubusercontent.com/u/151614?v=3","gravatar_id":"","url":"https://api.github.com/users/kuy","html_url":"https://github.com/kuy","followers_url":"https://api.github.com/users/kuy/followers","following_url":"https://api.github.com/users/kuy/following{/other_user}","gists_url":"https://api.github.com/users/kuy/gists{/gist_id}","starred_url":"https://api.github.com/users/kuy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuy/subscriptions","organizations_url":"https://api.github.com/users/kuy/orgs","repos_url":"https://api.github.com/users/kuy/repos","events_url":"https://api.github.com/users/kuy/events{/privacy}","received_events_url":"https://api.github.com/users/kuy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-21T07:02:23Z","updated_at":"2016-11-21T07:02:23Z","closed_at":null,"body":"This example code causes lots of flowtype errors.\r\n\r\n```javascript\r\nfunction toggleSomething(state: bool): void {\r\n  // Do something\r\n}\r\n\r\nexport default function* saga(): Generator<IOEffect,void,*> {\r\n  yield call(toggleSomething, true);\r\n}\r\n```\r\n\r\nHere is the output of errors.\r\n\r\n```\r\nsrc/sagas/control.js:65\r\n 65:   yield call(toggleSomething, true);\r\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type\r\n 65:   yield call(toggleSomething, true);\r\n             ^^^^ intersection\r\n  Member 1:\r\n  348:     & ContextCallFn\r\n             ^^^^^^^^^^^^^ ContextCallFn. See lib: flow-typed/npm/redux-saga_v0.11.x.js:348\r\n  Error:\r\n   65:   yield call(toggleSomething, true);\r\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on any member of intersection type\r\n  348:     & ContextCallFn\r\n             ^^^^^^^^^^^^^ intersection. See lib: flow-typed/npm/redux-saga_v0.11.x.js:348\r\n    Member 1:\r\n    338:     & (<R, C: Context, Fn: Fn0<R>>(cfn: [C, Fn], ...rest: Array<void>) => CallEffect0<C, Fn>)\r\n                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ polymorphic type: function type. See lib: flow-typed/npm/redux-saga_v0.11.x.js:338\r\n    Error:\r\n     65:   yield call(toggleSomething, true);\r\n                      ^^^^^^^^^^^^^^^ function. This type is incompatible with\r\n    338:     & (<R, C: Context, Fn: Fn0<R>>(cfn: [C, Fn], ...rest: Array<void>) => CallEffect0<C, Fn>)\r\n                                                 ^^^^^^^ tuple type. See lib: flow-typed/npm/redux-saga_v0.11.x.js:338\r\n    Member 2:\r\n    339:     & (<T1, R, C: Context, Fn: Fn1<T1, R>>(cfn: [C, Fn], t1: T1, ...rest: Array<void>) => CallEffect1<C, Fn, T1>)\r\n                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ polymorphic type: function type. See lib: flow-typed/npm/redux-saga_v0.11.x.js:339\r\n    Error:\r\n     65:   yield call(toggleSomething, true);\r\n                      ^^^^^^^^^^^^^^^ function. This type is incompatible with\r\n    339:     & (<T1, R, C: Context, Fn: Fn1<T1, R>>(cfn: [C, Fn], t1: T1, ...rest: Array<void>) => CallEffect1<C, Fn, T1>)\r\n                                                         ^^^^^^^ tuple type. See lib: flow-typed/npm/redux-saga_v0.11.x.js:339\r\n\r\n// ... {SNIP} ...\r\n\r\n  Member 9:\r\n  356:     & (<T, R, Fn: FnSpread<T, R>>(fn: Fn, ...args: Array<T>) => CallEffectSpread<null, Fn, T>);\r\n              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ polymorphic type: function type. See lib: flow-typed/npm/redux-saga_v0.11.x.js:356\r\n  Error:\r\n   61: function toggleSomething(state: bool): void {\r\n                                              ^^^^ undefined. This type is incompatible with\r\n  255:   declare type FnSpread<T, R> = (...args: Array<T>) => Promise<R>;\r\n                                                              ^^^^^^^^^^ Promise. See lib: flow-typed/npm/redux-saga_v0.11.x.js:255\r\n```\r\n\r\nI noticed that the definition of `Fn1` type doesn't consider a normal function.\r\n\r\n```javascript\r\ndeclare type Fn1<T1, R> = (t1: T1) => Promise<R> | Generator<*,R,*>;\r\n```\r\n\r\nSo I changed it to support my function `toggleSomething()`.\r\n\r\n```javascript\r\ndeclare type Fn1<T1, R> = (t1: T1) => void | Promise<R> | Generator<*,R,*>;\r\n```\r\n\r\nBut if I send a PR to this problem, I wonder how should I fix...? I understand `any | Promise<R> | Generator<*,R,*>` reduces the ability of flowtype's type checking.\r\nAny suggestion are welcome. Thanks!"}}
{"actor":{"display_login":"kuy"}}