Solución
solution.tsTypeScript
interface User {
id: number;
name: string;
email: string;
password: string;
role: string;
}
type PublicUser = Pick<User, "id" | "name" | "email">
type UserWithoutPassword = Omit<User, "password">
export function getPublicUser(): PublicUser {
return { id: 1, name: "Ana", email: "ana@mail.com" } as PublicUser;
}
export function getUserWithoutPassword(): UserWithoutPassword {
return { id: 1, name: "Ana", email: "ana@mail.com", role: "admin" } as UserWithoutPassword;
}0respuestas