You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I couldn't find a Flatten type for Objects, for a case like the following:
Being the keys dynamic, number of children unknown etc. I wanted a general solution.
The following is a single level flattening solution:
I have replaced
Object
andobject
toRecord<string, any>
to shut eslint ts errors up.I have no idea on why it works, but it does hehe. It was taken from here: https://flut1.medium.com/deep-flatten-typescript-types-with-finite-recursion-cb79233d93ca. The given link also shows up a multi level solution, for deeper object flattening.
Beta Was this translation helpful? Give feedback.
All reactions