type Role = 'admin' | 'editor' | 'viewer'; type Account = { id: number; name: string; role: Role; tags?: string[] }; function canEdit(account: Account): boolean { return account.role === 'admin' || account.role === 'editor'; } const account: Account = { id: 7, name: 'Lin', role: 'editor', tags: ['typescript'] }; console.log(canEdit(account));