Closed Peeja closed 1 year ago
I see the use case and I see it as interesting TS code. Just before merging, would you explain how this works input is U[number]
as I cannot understand what U[number]
means in this context?
Sure thing! It's a little odd, to be sure. Here, U
is an array type, indexed by number keys, so U[number]
means the type of an element of that array. U[0]
would be the type of the first element; U[number]
is the type of some element, without knowing which one, which makes it a union of all of the element types (even when it's a tuple and each element can have a different type).
U[keyof U]
may work just as well, now that I think of it, but I feel like I tried that and it ran into trouble for some reason.
Thanks for the info. I will merge it as it is, but I will try U[keyof U]
as if it works will be easier for others to understand. As with your other MR, I will inform you once NPM version is published.
Thanks! I agree, that reads much better, if it works.
closing as release was made and feature is now part of the code
In the specific case where
R.anyPass()
is combining unary type guards, it can now serve as a unary type guard itself. This allows you to do things like:I would have liked to do
allPass
as well for completeness, but the TypeScript is much more complex, and I'm not sure it comes up as much.