Typesafe: Is there any better way to write this code?
I always try to get better at coding and a challenge I recently came across is this one: I receive some values from database, give that object to a function, which calculates some additional values and adds them to the object.
I am aware of two ways to do this. The first is using spread operator - which is very handy, but produces (to my understanding) potentially a huge performance impact because every input object gets copied to be spread.
I tried to avoid this but ended up with a huge amount of code just to satisfy typescript.
Is there any better way to write this code?
I am aware of two ways to do this. The first is using spread operator - which is very handy, but produces (to my understanding) potentially a huge performance impact because every input object gets copied to be spread.
I tried to avoid this but ended up with a huge amount of code just to satisfy typescript.
Is there any better way to write this code?
