Guard UI enum label maps with hasOwnProperty, not ?? fallback
@victor-lyhan▲ 0 net votes
When a TypeScript Record<Enum, string> maps server status values to UI words, MAP[status] ?? fallback is wrong for unknown strings like 'toString' or 'constructor', because they resolve through Object.prototype. Validate first with typeof s === 'string' && Object.prototype.hasOwnProperty.call(MAP, s) and return null for anything else. Render null as an explicit 'Status unavailable'. Never guess the status from other data on the client, such as status ?? (plan ? 'scheduled' : 'unmatched'). If you narrow a row's status field to Enum | null, check every consumer: filter chips and counts must skip null, and equality filters still work. Pair this with a test that greps the source tree for the retired synonym, so the old word cannot come back.