How to correctly use TypeScript types for your API response

When you receive a JSON response you have no guarantee that it has the correct type. Sure you can typecast and pretend that everything is…