{"action":"opened","issue":{"url":"https://api.github.com/repos/piotrwitek/typesafe-actions/issues/63","repository_url":"https://api.github.com/repos/piotrwitek/typesafe-actions","labels_url":"https://api.github.com/repos/piotrwitek/typesafe-actions/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/piotrwitek/typesafe-actions/issues/63/comments","events_url":"https://api.github.com/repos/piotrwitek/typesafe-actions/issues/63/events","html_url":"https://github.com/piotrwitek/typesafe-actions/issues/63","id":344884371,"node_id":"MDU6SXNzdWUzNDQ4ODQzNzE=","number":63,"title":"isActionOf doesn't narrow properly with multiple actions ","user":{"login":"cjol","id":1517675,"node_id":"MDQ6VXNlcjE1MTc2NzU=","avatar_url":"https://avatars3.githubusercontent.com/u/1517675?v=4","gravatar_id":"","url":"https://api.github.com/users/cjol","html_url":"https://github.com/cjol","followers_url":"https://api.github.com/users/cjol/followers","following_url":"https://api.github.com/users/cjol/following{/other_user}","gists_url":"https://api.github.com/users/cjol/gists{/gist_id}","starred_url":"https://api.github.com/users/cjol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjol/subscriptions","organizations_url":"https://api.github.com/users/cjol/orgs","repos_url":"https://api.github.com/users/cjol/repos","events_url":"https://api.github.com/users/cjol/events{/privacy}","received_events_url":"https://api.github.com/users/cjol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-26T15:05:50Z","updated_at":"2018-07-26T15:05:50Z","closed_at":null,"author_association":"NONE","body":"Here's my minimal demo:\r\n\r\n```typescript\r\n\r\nimport { createAction, ActionsUnion } from \"typesafe-actions\";\r\nimport { filter, tap } from \"rxjs/operators\";\r\n\r\nconst actions = {\r\n  toggle: createAction(\"todos/TOGGLE\", resolve => {\r\n    return (id: string) => resolve(id);\r\n  }),\r\n  add: createAction(\"todos/ADD\", resolve => {\r\n    return (title: string) => resolve({ title, id: 5, completed: false });\r\n  }),\r\n  dummy: createAction(\"todos/DUMMY\", resolve => () => resolve({foo: true}))\r\n};\r\n\r\nexport type TestActions = ActionsUnion<typeof actions>;\r\n\r\n(action$: ActionsObservable<TestActions>) =>\r\n  action$.pipe(\r\n    filter(isActionOf([actions.add, actions.toggle])),\r\n    tap(x => x.type) // x.type:  \"todos/TOGGLE\" | \"todos/ADD\" | \"todos/DUMMY\"\r\n  );\r\n\r\nconst myFilter = isActionOf([actions.add, actions.toggle]);\r\n(action$: ActionsObservable<TestActions>) =>\r\n  action$.pipe(\r\n    filter(myFilter),\r\n    tap(x => x.type) // x.type:  string | \"todos/ADD\" | \"todos/TOGGLE\"\r\n  );\r\n```\r\n\r\nIn the first case, no narrowing is done at all. In the second case (which I discovered by trying to inspect the result of isActionOf directly), some narrowing seems to be done, but it's also unioning with an empty action, so that x is basically unusable. The type given to `myFilter` is:\r\n\r\n```typescript\r\nconst myFilter: (action: {\r\n    type: string;\r\n}) => action is {\r\n    type: \"todos/TOGGLE\";\r\n    payload: string;\r\n} | {\r\n    type: \"todos/ADD\";\r\n    payload: {\r\n        title: string;\r\n        id: number;\r\n        completed: boolean;\r\n    };\r\n} | {\r\n    type: string;\r\n}\r\n```\r\n\r\nAm I doing something wrong?"}}
{"actor":{"display_login":"cjol"}}