1. With explicit type arguments. Everything is fine.
2. With inferred type arguments. P cannot be inferred, because it does not relate to any method argument.
3. With one explicit type argument. But why is the second argument not inferred?
const incrementAction = createAction
const actionCreator2 = createAction(type);
const actionCreator3 = createAction
Here `createAction` infers `T` and `withPayload` is called with `number` explicitly.
But this requires a change in our existing runtime code, and it is a bit weird to use.
const incrementAction = createAction("increment" as const)
Actually, our `createAction` function can take an optional second `prepare` argument to modify the payload beforehand.
Here we just create a helper fn that captures a type and returns a `prepare` function that just passes the payload through. ());" src="/images/1px.png" data-src="https://pbs.twimg.com/media/EOQ6HCXXUAYaEIi.jpg">
Next week, you will learn how you can add restrictions to your type parameters.
After all, right now you could pass any object as `T` parameter, and we don't want that.