0 of 7 problems solved0%
2 of 7

Omit Secrets

Omit<Type, Keys> removes specific properties from a type. Use it when you need a safe public view of a private model. At runtime, construct a new object without the excluded property.

// Example: remove a secret field from a profile
type Public = Omit<{ email: string; token: string }, "token">;

Your Task

Return a public user object without the password.

  • Define type User = { id: string; email: string; password: string; role?: 'user' | 'admin' }.
  • Define type PublicUser = Omit<User, 'password'>.
  • Implement function sanitize(u: User): PublicUser returning a new object without password.
  • Preserve other fields; do not mutate u.