Skip to content

feat(scripts/generate-phosphor-icon-registry): reject bare icon names via a generated module declaration - #1099

Merged
sukvvon merged 1 commit into
mainfrom
refactor/phosphor-suffixed-types
Aug 3, 2026
Merged

feat(scripts/generate-phosphor-icon-registry): reject bare icon names via a generated module declaration#1099
sukvvon merged 1 commit into
mainfrom
refactor/phosphor-suffixed-types

Conversation

@sukvvon

@sukvvon sukvvon commented Aug 3, 2026

Copy link
Copy Markdown
Member

Follow-up to #1094, implementing @SeanCassiere's suggestion there.

#1094 renamed every icon import to the Icon-suffixed export, but the deprecated spelling is still exported, so import { Star } remains a strikethrough rather than an error — nothing stops the old names from creeping back.

Phosphor doesn't ship a suffixed-only entrypoint like Lucide's lucide-react.suffixed, so export * from '...' has nothing to point at: the barrel does export * from './csr/Star' ×1512, and each icon module exports both Star and StarIcon. Redeclaring the module with only the suffixed members gets the same result.

Changes

scripts/generate-phosphor-icon-registry.mjs now emits a second artifact, src/types/phosphor-icons.generated.d.ts, from the same dist/csr scan that already builds the DS registry. It declares @phosphor-icons/react with the 1512 suffixed exports plus the barrel's non-icon members (Icon, IconProps, IconWeight, IconContext, IconBase, SSR) — the ambient declaration replaces the barrel's types wholesale, so omitting any of those would break every consumer of them.

error TS2305: Module '"@phosphor-icons/react"' has no exported member 'Star'.

Validation

Subpaths in the declaration follow the package's own exports map (./lib, ./ssr, ./*). This matters more than it looks: pointing at the underlying dist/lib path instead resolves to nothing, and with skipLibCheck: true that failure is silent — every re-exported symbol quietly degrades to any. An import-only smoke test passes either way, so correctness was checked negatively:

  • const w: IconWeight = 'nope' → TS2322
  • <StarIcon weight="nope" /> → TS2322
  • <StarIcon notAProp={1} /> → TS2322
  • import { Star } → TS2305
  • import { StarIcon }, the five non-icon exports, and subpath imports (@phosphor-icons/react/Acorn, used by the generated registry) → clean
  • tsc --skipLibCheck false reports nothing originating in the generated declaration

pnpm test passes (143 tests, 1 environment-gated skip); oxlint and oxfmt clean; re-running icons:generate is a no-op.

Known limitations

  • SSR.Star still resolves. The namespace re-export passes the SSR module through untouched, so bare names survive behind SSR.*. Nothing in src/ imports SSR, so this is a stated gap rather than a regression.
  • Upgrading @phosphor-icons/react requires re-running pnpm icons:generate. Until then a newly added icon isn't in the declaration, and a valid import reads as TS2305. A CI drift check would close this; it isn't included here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved icon package compatibility by ensuring icon components and related types are correctly available.
    • Preserved access to supported utility, context, base component, and server-rendering exports.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fd1beb37-7311-467f-97e8-4e5a0fc06a2b

📥 Commits

Reviewing files that changed from the base of the PR and between 9002836 and 2c7a755.

⛔ Files ignored due to path filters (1)
  • src/types/phosphor-icons.generated.d.ts is excluded by !**/*.generated.*
📒 Files selected for processing (1)
  • scripts/generate-phosphor-icon-registry.mjs

📝 Walkthrough

Walkthrough

The icon registry generator now creates a TypeScript declaration for @phosphor-icons/react. The declaration exports only Icon-suffixed icons while preserving required supporting exports and the SSR namespace.

Changes

Phosphor icon registry

Layer / File(s) Summary
Generate restricted Phosphor declarations
scripts/generate-phosphor-icon-registry.mjs
The generator emits src/types/phosphor-icons.generated.d.ts with suffixed icon exports, supporting types, context, base component, and SSR exports. Bare icon names become compile-time errors.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Suggested reviewers: abeuty

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: generating a module declaration that rejects bare icon names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/phosphor-suffixed-types

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 2c7a755 Commit Preview URL

Branch Preview URL
Aug 03 2026, 12:47 AM

@sukvvon
sukvvon requested review from a team and SeanCassiere August 3, 2026 02:23
@sukvvon sukvvon self-assigned this Aug 3, 2026
@sukvvon
sukvvon merged commit e210978 into main Aug 3, 2026
7 checks passed
@sukvvon
sukvvon deleted the refactor/phosphor-suffixed-types branch August 3, 2026 04:34
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.

2 participants