Solución
solution.tsTypeScript
type ApiResponse = { kind: "success"; data: string }
type ApiResponseError = { kind: "error"; message: string }
export function formatApiResponse(response: ApiResponse | ApiResponseError): string {
switch (response.kind) {
case "success":
return "OK: " + response.data
case "error":
return "ERR: " + response.message
}
}0respuestas