Conversation
d6516f2 to
4ec83f5
Compare
Why would you want to pass null and undefined to |
I don't think it's about strictness. The innocent-looking code ends up with a wrong type rather than an imprecise type. Alternatively, the methods could return
This is a minimal example. In reality, we often don't have the luxury to know what values (or even types in the case of generics) we get. Passing in a constant
I think having 9 overloads instead of 4 is a small price to pay. I think these 9 overloads are also easier to comprehend since they handle all cases systematically and correctly. The pattern is fairly clear. (Though I'm obviously biased because I wrote that.) Sadly, I haven't found a less bloated way. |
05b3a77 to
1d9a130
Compare
1d9a130 to
5e0949c
Compare
e13d6c5 to
cd6e044
Compare
The
atmethod overloads do not handle all cases correctly. Both key and value transformers can independently have typeundefined,TransformerorTransformer | undefined. In the later case, the return value would need to be a union type. That's total of 9 combinations (in addition toGetSubspacecase).Example:
That code would pass the type checking with the current overloads but is actually invalid.