seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
649 stars 13 forks source link

Make the Composable type easier on the eyes #162

Closed diogob closed 1 month ago

diogob commented 1 month ago

Before the type Composable would be diplayed as:

const f = composable((x: number) => x)
//    ^? ((x: number) => Promise<Result<number>>) & { kind: "composable"; }

This was really bothering me when using the library, particularly when dealing with composables with an already cluttered return type. After this PR it resolves to a new type we don't export called ComposableFunction:

const f = composable((x: number) => x)
//    ^? ComposableFunction<(x: number) => number>