Fix wrong variable name and API in README.invariant.md "Documenting impossible states" example#84
Fix wrong variable name and API in README.invariant.md "Documenting impossible states" example#84ooloth wants to merge 1 commit into
Conversation
#29 The "Documenting impossible states" code block used `emojiMap.get(symbol)` — a Map API call on a nonexistent variable. The real code in `ui/elements/emoji.tsx` uses plain object bracket access on `emojiLabel`: `const ariaLabel = emojiLabel[symbol]`. There is no `emojiMap` variable and no `.get()` call anywhere in the codebase. Closes #29
Code ReviewOverviewThis is a single-line documentation fix in Correctness ✅Verified against
The old example would throw Code Quality
SuggestionsNone required for this fix. One optional improvement to consider separately:
VerdictLGTM. Simple, correct, well-scoped fix. Safe to merge. |
There was a problem hiding this comment.
Pull request overview
Updates the invariant usage guidelines to ensure the “Documenting impossible states” example matches the real emoji implementation in the UI codebase, preventing copy/paste errors from the documentation.
Changes:
- Replaces the incorrect
emojiMap.get(symbol)example withemojiLabel[symbol]to reflect the actual data structure and variable name used inui/elements/emoji.tsx.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What
emojiMap.get(symbol)toemojiLabel[symbol]in the "Documenting impossible states" code block — the real code uses plain object bracket access onemojiLabel, not a Map API call on a nonexistent variableWhy
emojiMapdoes not exist in the codebase andemojiLabelis a plain object, not a MapHow to validate
utils/errors/README.invariant.mdand find the "Documenting impossible states" block — expectconst ariaLabel = emojiLabel[symbol](plain object access, correct variable name)ui/elements/emoji.tsxline 30 — expect the same expressionemojiLabel[symbol], confirming the example matches the real codeCloses #29
Related links
Generated by Claude Code