fix(compiler): conditionally restore prop: branch in OneOf helper - #6855
Open
rajat12826 wants to merge 1 commit into
Open
fix(compiler): conditionally restore prop: branch in OneOf helper#6855rajat12826 wants to merge 1 commit into
rajat12826 wants to merge 1 commit into
Conversation
Restores the 3-way exclusive union for `OneOf` on components with 5 or fewer required props. This reenables `prop:` overrides for overlapping keys like `aria` while maintaining the fix from stenciljs#6804 to prevent TS2590 on components with many required props.
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.
Description
This PR fixes an issue where objects could no longer be passed to required
aria-*props via JSX (prop:aria={...}) since 4.44.0.Because Stencil's
HTMLAttributesincludes a template literal index signature foraria${string}, passing an object shape to a requiredariaprop fails standard property assignment. Theprop:ariaprefix historically bypassed this, but #6804 removed theprop:branch from the generatedOneOfhelper entirely to preventTS2590("union type too complex") on components with 8+ required props.The Fix:
This PR re-introduces the 3-way exclusive branch version of
OneOf(which supports theprop:option) conditionally, only for components with 5 or fewer required props (MAX_ONE_OF_REQUIRED_PROPS_WITH_PROP = 5).This cleanly balances both needs:
prop:overrides for complex types that overlap with standard HTML attributes.Related Issue(s)
Fixes #6854
Testing
prop:aria={{ 'aria-label': 'Close' }}compiles correctly for components below the 5-prop threshold.