Ritu Singh
This approach makes use of recursion.
It needs a bit of tidying up and error trapping. The data objects here are record-based value objects which simplify cloning.
The object code:
Suggested blogs:
>How to assign multiple const variables in a single declaration in TypeScript?
>How to handle more than 100 cases neatly on Typescript?
>Type inference with 'as const' IN TypeScript
>Typescript Return argument: Tuple type or passed to rest parameter warning?
>How can you read a Blob in Deno in TypeScript?
>How to do Yup validation in form with TypeScript?
>How can I merge two arrays of objects that can be undefined in TypeScript?
>Javascript Error Solved: Property 'id' does not exist on type 'T'