Solución
solution.tsTypeScript
export function getUserCity(user: { city: string } | null): string | null {
// Usa && para acceder a user.city de forma segura
// if (user !== null) {
// return user.city;
// }
return user != null && user.city !== undefined ? user.city : null;
}0respuestas