DEV Community

Discussion on: Creating a typed "compose" function in TypeScript

Collapse
 
ascorbic profile image
Matt Kane

Hi Sebastian,
This isn't as smart as that: it expects that they all return the same type. If be interested to see if there's a way of typing the other sort though.

Collapse
 
skurfuerst profile image
Sebastian Kurfürst

Hey Matt,

the only way I see it is via N+1 different generic types - though that is ofc. not as nice as your generic implementation.

See:

All the best, Sebastian

Thread Thread
 
stereobooster profile image
stereobooster

There is a way to simulate it, but wiht limitations github.com/reduxjs/redux/blob/686d...

Thread Thread
 
ascorbic profile image
Matt Kane

Yeah, I can't see any way that doesn't boil down to "use lots of repetitive overloads"