找出公共账户类型里的 bug

来自 工具类型
TypeScript 6 进阶 5分钟 找出 1处问题

找出这个公开账户辅助函数没有脱敏密码哈希的原因。

TypeScript
interface Account {
  id: string;
  displayName: string;
  passwordHash: string;
}
type PublicAccount = Omit<Account, "passwordHash">;

function toPublic(account: Account): PublicAccount {
  return account;
}

console.log(JSON.stringify(toPublic({
  id: "a-1", displayName: "Mina", passwordHash: "secret"
})));
在试验场中打开
报告错误