Repository navigation
6.x bugfixes - #5746
Merged
Merged
6.x bugfixes#5746
Conversation
🦋 Changeset detectedLatest commit: 88780fe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
quantizor
force-pushed
the
may-bugfixes-6.x
branch
from
May 14, 2026 18:16
8612caa to
88780fe
Compare
There was a problem hiding this comment.
Pull request overview
This PR bundles several v6.x bugfixes across runtime behavior, TypeScript typings, and RSC handling, plus accompanying tests and changesets.
Changes:
- Adjust RSC CSS emission logic for styled component inheritance chains and add related test utilities/snapshots.
- Fix/extend runtime guards and interpolation behavior (Preact
forwardRefcarrier detection; plain-object customtoStringinterpolation). - Improve TypeScript polymorphic
as/forwardedAsbehavior and JSX prop IntelliSense, with new type-level tests and release notes.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/styled-components/src/utils/test/stylisPluginRSC.test.tsx | Comment punctuation update in RSC stylis plugin tests. |
| packages/styled-components/src/utils/test/stylis.test.ts | Comment punctuation updates in stylis tokenizer tests. |
| packages/styled-components/src/utils/test/isStyledComponent.test.ts | Adds coverage for Preact forwardRef shape and HOC false-positive prevention. |
| packages/styled-components/src/utils/test/flatten.test.tsx | Adds test ensuring plain objects with custom toString stringify as values. |
| packages/styled-components/src/utils/stylisPluginRSC.ts | Comment punctuation update. |
| packages/styled-components/src/utils/nonce.ts | Comment punctuation update. |
| packages/styled-components/src/utils/isStyledComponent.ts | Tightens styled-component detection to include $$typeof forwardRef branding and function carriers. |
| packages/styled-components/src/utils/flatten.ts | Treats plain objects with custom toString as value interpolations instead of rule objects. |
| packages/styled-components/src/types.ts | Type fixes for polymorphic components (as prop conflicts; JSX completion via overload ordering). |
| packages/styled-components/src/test/types.tsx | Adds type tests for as conflict override and JSX completion behavior. |
| packages/styled-components/src/test/treeshake.test.ts | Comment punctuation update. |
| packages/styled-components/src/test/styles.test.tsx | Adds runtime test for interpolated value objects calling toString. |
| packages/styled-components/src/test/ssr-memory.test.tsx | Comment punctuation update. |
| packages/styled-components/src/test/rehydration.test.tsx | Comment punctuation update. |
| packages/styled-components/src/test/ordering.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/test/memoization.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/test/hmr-createTheme.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/test/basic.test.tsx | Adds regression test for chain folding under Preact-style function forwardRef. |
| packages/styled-components/src/test/attrs.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/sheet/dom.ts | Comment punctuation update. |
| packages/styled-components/src/models/StyleSheetManager.tsx | Comment punctuation updates. |
| packages/styled-components/src/models/StyledComponent.ts | Updates RSC inline <style> emission strategy; adds resetIdentifiers for test stability; switches to per-name compiled CSS reads. |
| packages/styled-components/src/models/Keyframes.ts | Comment punctuation update. |
| packages/styled-components/src/models/InlineStyle.ts | Comment punctuation updates. |
| packages/styled-components/src/models/GlobalStyle.ts | Comment punctuation update. |
| packages/styled-components/src/models/ComponentStyle.ts | Adds getCompiledCSSForName helper for RSC emission. |
| packages/styled-components/src/constructors/test/styled.rsc.test.tsx | Updates RSC snapshots, resets component-id counters, and updates test descriptions/comments. |
| packages/styled-components/src/constructors/test/createTheme.test.tsx | Comment punctuation update. |
| packages/styled-components/src/constructors/test/createGlobalStyle.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/constructors/test/createGlobalStyle.ssr.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/constructors/test/createGlobalStyle.rsc.test.tsx | Comment punctuation updates. |
| packages/styled-components/src/constructors/styled.tsx | Comment punctuation update. |
| packages/styled-components/src/constructors/createTheme.ts | Comment punctuation updates. |
| packages/styled-components/src/constructors/createGlobalStyle.ts | Comment punctuation update. |
| packages/styled-components/src/constants.ts | Fixes DISABLE_SPEEDY default when process is unavailable in browser bundles. |
| packages/styled-components/src/bench/rsc.test.tsx | Comment punctuation update. |
| packages/styled-components/docs/faq.md | Comment punctuation update (but also contains an RSC dedup claim needing alignment with behavior). |
| .changeset/issue-5738-process-global.md | Patch release note for process-less production bundles. |
| .changeset/fix-wrapped-as-prop-conflict.md | Patch release note for as prop type conflicts when wrapping components. |
| .changeset/fix-value-object-tostring.md | Patch release note for custom toString value objects in interpolations. |
| .changeset/fix-preact-chain-fold.md | Patch release note for Preact react-compat chain folding with as. |
| .changeset/fix-jsx-prop-intellisense.md | Patch release note for JSX prop autocomplete regression. |
Comments suppressed due to low confidence (2)
packages/styled-components/src/models/StyledComponent.ts:343
- The RSC emission loop assumes a 1:1 mapping between
componentStylechain levels and entries ingeneratedClassName.split(' ')(it decrementsnameIdxon everywalk = walk.baseStyle). If an intermediateComponentStylelayer has no CSS (e.g.styled(Base)```) but its base does, the nextnameactually belongs to a deeperwalkand this loop will fetch the wrong CSS (often falling back to an empty group), dropping ancestor styles. Consider only consuming/decrementingnameIdxwhen the currentwalk.componentIdactually registered thatname(e.g. viastyleSheet.hasNameForId`) and otherwise skipping the CSS-less level without consuming a name.
let walk: ComponentStyle | null | undefined = componentStyle;
while (walk) {
const names = ssc.styleSheet.names.get(walk.componentId);
if (names) {
packages/styled-components/src/constructors/test/styled.rsc.test.tsx:1202
- These RSC tests still assert cross-instance style-tag deduplication (
countStyleTags(html) === 1), but the currentIS_RSCbranch inStyledComponent.tsalways returns a<style>tag whenevercombinedis non-empty and no longer consults any per-render "emitted names" set for component rules. Unless the runtime is expected to dedupe styles elsewhere, these expectations will fail; either update the tests to match per-instance emission or reintroduce a safe dedup strategy.
});
it('should emit only one style tag for dynamic components with identical props', () => {
const Box = styled.div<{ $color: string }>`
color: ${p => p.$color};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ``` | ||
|
|
||
| RSC environments are detected automatically—no configuration required. Styles are emitted alongside each component's markup and deduplicated per render. | ||
| RSC environments are detected automatically - no configuration required. Styles are emitted alongside each component's markup and deduplicated per render. |
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.
Fixes #5741
Fixes #5740
Fixes #5738
Fixes #5736
Fixes #5734