Skip to content

Fix wrong variable name and API in README.invariant.md "Documenting impossible states" example#84

Open
ooloth wants to merge 1 commit into
mainfrom
claude/issue-29
Open

Fix wrong variable name and API in README.invariant.md "Documenting impossible states" example#84
ooloth wants to merge 1 commit into
mainfrom
claude/issue-29

Conversation

@ooloth
Copy link
Copy Markdown
Owner

@ooloth ooloth commented May 20, 2026

What

  • Corrects emojiMap.get(symbol) to emojiLabel[symbol] in the "Documenting impossible states" code block — the real code uses plain object bracket access on emojiLabel, not a Map API call on a nonexistent variable

Why

  • A reader copying this snippet would get a reference error: emojiMap does not exist in the codebase and emojiLabel is a plain object, not a Map

How to validate

  • Open utils/errors/README.invariant.md and find the "Documenting impossible states" block — expect const ariaLabel = emojiLabel[symbol] (plain object access, correct variable name)
  • Open ui/elements/emoji.tsx line 30 — expect the same expression emojiLabel[symbol], confirming the example matches the real code

Closes #29

Related links


Generated by Claude Code

#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
@claude
Copy link
Copy Markdown

claude Bot commented May 20, 2026

Code Review

Overview

This is a single-line documentation fix in utils/errors/README.invariant.md. It corrects a code example that used a nonexistent variable (emojiMap) and the wrong API (.get() from Map) — replacing it with the actual expression from ui/elements/emoji.tsx (emojiLabel[symbol], plain object bracket access).


Correctness ✅

Verified against ui/elements/emoji.tsx:

  • Line 3: const emojiLabel = { ... } — plain object, not a Map
  • Line 30: const ariaLabel = emojiLabel[symbol] — matches the fix exactly

The old example would throw ReferenceError: emojiMap is not defined if copied verbatim. The new example is accurate.


Code Quality

  • Minimal and focused — one line changed, no unrelated edits.
  • No style issues — the surrounding markdown is untouched.
  • The comment on the line below (// Documents that our emoji map should be complete) uses the word "map" loosely (meaning "lookup table"), which is slightly confusing given the bug just fixed, but it's pre-existing and not introduced by this PR. Worth a follow-up if it causes confusion.

Suggestions

None required for this fix. One optional improvement to consider separately:

  • The comment // Documents that our emoji map should be complete could be clarified to // Documents that emojiLabel should cover all EmojiSymbol values to avoid the ambiguity between "map" (the data structure) and "map" (the lookup table). That's out of scope here though.

Verdict

LGTM. Simple, correct, well-scoped fix. Safe to merge.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with emojiLabel[symbol] to reflect the actual data structure and variable name used in ui/elements/emoji.tsx.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix wrong variable name and API in README.invariant.md "Documenting impossible states" example

2 participants