Add Support for Multiple Types in a Type Helper
The solution here is nice and simple:
type CreateDataShape<TData, TError> = { data: TData; error: TError;};
Using the comma operator between TData
and TError
allows us to specify multiple generics.
I haven't found a hard limit on the number of generics that can be added, and I
Transcript
0:00 The solution here is nice and simple. What we have here is a TData and a TError. We can use the comma operator here to specify multiple generics here. We can actually just go as far as we want to. We can go T3, T4, T5, T6.
0:14 I'm not sure what the hard limit is actually for the number of generics here, and I've certainly never found it. I've seen them with many, many, many of them as well. This CreateDataShape, nice and simple exercise.
0:28 It means that you can actually compose lots of these together, just as you pass many, many arguments to a function.