Skip to content

Fix wrong variable name in README.invariant.md "Documenting Complete Mapping" example #31

@ooloth

Description

@ooloth

Why

The "Good: Documenting Complete Mapping" example uses emojiLabels (plural), but the real variable in ui/elements/emoji.tsx is emojiLabel (singular), so a reader copying the snippet gets a reference error.

Current state

utils/errors/README.invariant.md line 200:

// ui/emoji.tsx
const ariaLabel = emojiLabels[symbol]
invariant(ariaLabel, 'Emoji must have aria-label', { symbol })
// Documents that our emoji map should cover all symbols

ui/elements/emoji.tsx declares const emojiLabel = { … } as const (singular, no s) and accesses it as emojiLabel[symbol]. The identifier emojiLabels does not exist in that file.

Note: the comment also cites ui/emoji.tsx but the actual file is at ui/elements/emoji.tsx.

Ideal state

  • The example uses emojiLabel[symbol] (singular) to match the real identifier.
  • The path comment reflects the actual file location ui/elements/emoji.tsx.

Starting points

  • utils/errors/README.invariant.md — lines 198–203, the "Good: Documenting Complete Mapping" block
  • ui/elements/emoji.tsx — line 3 (const emojiLabel), line 30 (emojiLabel[symbol])

QA plan

  1. Open utils/errors/README.invariant.md and read the "Good: Documenting Complete Mapping" example — expect emojiLabel[symbol] (singular) and path comment ui/elements/emoji.tsx.
  2. Open ui/elements/emoji.tsx — expect to find const emojiLabel (singular) and emojiLabel[symbol] on line 30.

Done when

The "Documenting Complete Mapping" example uses the correct identifier emojiLabel[symbol] and cites the correct file path ui/elements/emoji.tsx.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions