I'm trying to make a recursive generic type to convert nested object values from Dates to strings. I'm having trouble with the conversion and making the types line up, especially around arrays. https://www.typescriptlang.org/play?jsx=0#code/C4TwDgpgBAIghsCATAPAFQHxQLxTVCAD0QDskBnWBCAKCigH4pzgAnASxIHM6oAuPAWIQylOCRABtALq8m8RKkwzeA-EVIUoAewBGAKwgBjYHKgBvKJIDWEEFE5RbIbQDM80gQuTobd6VgAvqp4ANw0NERg2qzAUEbaJCzM4uzA7ABeEN6UuOgYABQAbnAANgCuEGoAlF7USljYWOa87O4FAIKsrHAgAHTs5F09IMVlldXVFrz0CUlxALZwYJBIODP0UCUVEH1LYOhCmpQFnK4QrFAAqtUyjFSKKFdYAiQQRReF5KnpWTnV4U2UFYEGA5VYJCg+1WgKgwVmiWSINyG22lQc83ERggbgetCB9CYaN2wG0AEkAMoAeQpbE4XAK1Q29AExIxLCxOPcVIMxlMBPuPMMJj6IjpEHIYx21T6IKQ5WxKG8DUKzIJBTgRiMABorM5dcTpFMmlACi0BQK+lbNTq1QK-CBPCkSGlMtlqJLidVtXbNoFvb76OZAlA4JRlflfUyBazxhBYSCwRDgRLwoFwkA
I'm doing this to serialize data from server -> client in next.js, and all Dates in the object sent to the client must be converted to strings
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.