Make catalogue component lookup casing-tolerant#2563
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
Fall back to a lowercased catalogue lookup in the reconciler so casing typos like <powerSource> resolve to the registered component instead of throwing "Unsupported component type". Generated-By: PostHog Code Task-Id: 0d99d5ae-142e-46db-afff-5346e4da7e51
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The React reconciler resolves JSX element names against the catalogue with an exact-match lookup (
catalogue[type]), which throws "Unsupported component type" for casing typos. The catalogue only registers each component under its PascalCase class name (PowerSource) and a fully-lowercased alias (powersource), so a camelCase tag like<powerSource>matches neither and blows up even though the component clearly exists.This adds a lowercased fallback (
catalogue[type] ?? catalogue[type.toLowerCase()]) before throwing, sopowerSource/PowerSource/powersourceall resolve to the same component. It's a one-line change that kills this whole class of casing errors for every component in the catalogue.Why
A user hit this error from a
<powerSource>camelCase typo. The error message points at a nonexistent registration bug, sending people hunting in the wrong place. The fix makes the lookup typo-tolerant so a casing mistake resolves cleanly instead.Test plan
Added
tests/fiber/camelcase-component-fallback.test.tsxasserting camelCase and PascalCase string element types resolve to the same constructor as the canonical lowercase element.bunx tsc --noEmitpasses.Created with PostHog Code from an inbox report.