seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
665 stars 14 forks source link

Simplify Unpack types #60

Closed gustavoguichard closed 1 year ago

gustavoguichard commented 1 year ago

Purpose

I found a new way to map over a list in TS. It reduces a lot of the complexity I introduced to the types.ts file earlier and makes that file more approachable.

Tech details

Now that we have type tests (#58) it gets easier to refactor at type level 🤤

I also changed some types to use Tail recursion elimination which might improve TS perf.

Concerns

The List and ListToResultData types along with all the nested types in List were "leaking" to the public API even though we didn't document them. It can be seen here.

I think and hope no one used it but if they did we are introducing a type level breaking change.

I don't feel like bumping the major but not sure what we should do here... maybe leave those types as deprecated?

This got me to think we should stop doing:

// ./src/index.ts
export * from './types.ts'

Maybe we can have a separate file for public types:

// ./src/public-types.ts
export { Cherry, Picked, Types } from './types.ts'

So we export all of them from the index.ts:

// ./src/index.ts
export * from './public-types.ts'

What do you think?