Thanks a lot for the translation 😇 a read the comments below and that pretty nice 💪
some guy found issue with merging inconsistent arrays [{ a: 'a' }, { b: 'b'}]... I know about it and I already resolved it... but the solution is too complicated (and large) to keep it in one article... So I have a plan to do the second part of it where I'll resolve this edge-case + Add the optional length of types to merge... something like: DeepMergeMany<A, B, C, D, ...>
Hi @stepan Zubaslev! It took few months but I did it! :D
I just refactored half of the article and I add
Support for better typescript help
Fix many edge cases which I mention a few months ago.
At the moment the basic type like { a: [{ a: 'a' }, { b: 'b'}] } is working and DeepMergeTwoTypes<T, U> generic will resolve and merge this array (tuple) structure correctly, like in the screenshots in the article.
I hope you'll like these newly refactored upgrades!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article. Thank you for it! The more TS recepies we have the better types we can write. Especially thanks for this hack with a tuple and if-else.
One note: There's type PropertyKey. It'd be better to use it instead of
string
. But... TS dissalow it. It even dissallows usingstring | number
. Hm...P.S. a translated this article to Russian there ( habr.com/en/post/526998/ ).
Hi dude
Thanks a lot for the translation 😇 a read the comments below and that pretty nice 💪
some guy found issue with merging inconsistent arrays
[{ a: 'a' }, { b: 'b'}]
... I know about it and I already resolved it... but the solution is too complicated (and large) to keep it in one article... So I have a plan to do the second part of it where I'll resolve this edge-case + Add the optional length of types to merge... something like:DeepMergeMany<A, B, C, D, ...>
So I'll see 😏
Hi @stepan Zubaslev! It took few months but I did it! :D
I just refactored half of the article and I add
At the moment the basic type like
{ a: [{ a: 'a' }, { b: 'b'}] }
is working andDeepMergeTwoTypes<T, U>
generic will resolve and merge this array (tuple) structure correctly, like in the screenshots in the article.I hope you'll like these newly refactored upgrades!