3 ms·
But you can type 'pipe' correctly in Typescript, without resorting to overloads: https://code.lol/post/programming/typesafe-function-composition/ https://code.
by mpoteat 4y ago
But you can type 'pipe' correctly in Typescript, without resorting to overloads:
https://code.lol/post/programming/typesafe-function-composition/ https://code.lol/post/programming/typesafe-function-composit...
It's even more powerful if you restrict yourself to point free semantics - then you can use higher kinded types to do generic-level variadic composition.
As well, optional generics are trivially achievable in TS via default type parameters, unless I'm not understanding that section of the article.
- Tade0 4y agoGood write up. I had a feeling some form of this must've been possible, especially that with newer versions of TS the compiler has become increasingly better at handling recursive types and doesn't throw the dreaded TS2589 error nearly as often.
- modestygrime 4y ago> As well, optional generics are trivially achievable in TS via default type parameters, unless I'm not understanding that section of the article. He links to another post that goes into more detail: https://effectivetypescript.com/2020/12/04/gentips-1-curry/ https://effectivetypescript.com/2020/12/04/gentips-1-curry/ In particular the question and answer in the comments should make it more clear.