gcanti/redux-tcomb

createActionType requires at least 2 actions

Closed this issue · 3 comments

It's a small thing, but made me wonder for a while. I am trying to setup things and had only single action there to see it working. Unfortunately that fails with tcomb.union

TypeError: [tcomb] Invalid argument types [
  "FIRST_ACTION"
] supplied to union(types, [name]) combinator (expected an array of at least 2 types)

I am not entirely sure yet why that union is there, but should be handled more properly I guess.

I guess we could add a check here https://github.com/gcanti/redux-tcomb/blob/master/lib/createActionType.js#L13
If there is only one type, do not build the union and just return that type

Yes sure, or more likely in that case the Action should probably equal to types[0] so it still works for other mechanics.

should probably equal to types[0]

Yes, I meant exactly that. Again, would you like to send a PR? Note: action creators should be exported as well, even if there is only one type