gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.38k stars 57 forks source link

refact: PartialDeep alignment for different structures #72

Closed Beraliv closed 1 year ago

Beraliv commented 1 year ago

Summary

Align type gaps for different structures:

Why

There are a lot of gaps in the implementation, I've covered all of them with tests

Let me know what happens with types that are extended (e.g. Error can be extended and usually people do that so I didn't include it in the list)

Beraliv commented 1 year ago

cc @gvergnaud @ecyrbe let me know what you think, I do agree this type can be simpler, but it has a lot of gaps that I'm happy to fix (I can do it for all deep types that are implemented)

If you're happy with this change, I will update all of them:

gvergnaud commented 1 year ago

@Beraliv Thanks for fixing all of these edge cases, that looks great! What do you think about generalizing the PartialDeep function into a TransformDeep one taking a mapper function to run on every object level?

Pushed a few commits to your branch with a proof of concept of this. It's lacking doc comments as well as unit tests, but if you find it interesting I'll let you take it from there :)

Beraliv commented 1 year ago

@Beraliv Thanks for fixing all of these edge cases, that looks great! What do you think about generalizing the PartialDeep function into a TransformDeep one taking a mapper function to run on every object level?

Pushed a few commits to your branch with a proof of concept of this. It's lacking doc comments as well as unit tests, but if you find it interesting I'll let you take it from there :)

Absolutely, let me have a look at it later today and I will try to play with it this week

gvergnaud commented 1 year ago

Fixed the remaining things, added doc and reformatted tests. I don't think we need to care too much about intersections with primitive types until we have an explicit feature request for this