Comment by nine_k
16 hours ago
The examples of bad, overly complex types are indeed unpleasant and unwieldy: colossal, highly nested types with long, cryptic lists of type parameters.
I think this speaks of lack of abstraction, not excess of it.
If your type has 17 type parameters, you likely did not abstract away some part of it that can be efficiently split out. If your type signature has 9 levels of parameter type nesting, you likely forgot to factor out quite a bit of intermediate types which could have their own descriptive names, useful elsewhere.
Unfortunately many languages have poor support for named type definitions and higher order types, unlike e.g. Haskell. That would definitely help to avoid these problems.
This is so, but Tyepscript has a pretty good support for that.
TS doesn't support higher order types. You can't return a generic and pass its parameters later. It's basically only a single level of parametrization.
``` type MyGeneric<TParam> = ...; type HigherOrderGeneric<TParam> = TParam extends string ? MyGeneric : never;
type Hey = HigherOrderGeneric<string><number>;
```
There are libraries that try to achieve this through some hacks, tho their ergonomics are really bad.