You should take a look at https://zod.dev/ if you haven't already - it's a library for runtime parsing that works really well for your use case.
Types are inferred from the schema though personally I like to handwrite types as well to sense check that the schema describes the type I think it does
Types are inferred from the schema though personally I like to handwrite types as well to sense check that the schema describes the type I think it does