Skip to content

6.x bugfixes - #5746

Merged
quantizor merged 3 commits into
6.xfrom
may-bugfixes-6.x
May 14, 2026
Merged

quantizor merged 3 commits into
6.xfrom
may-bugfixes-6.x

Conversation

@quantizor

@quantizor quantizor commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5741
Fixes #5740
Fixes #5738
Fixes #5736
Fixes #5734

@changeset-bot

changeset-bot Bot commented May 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 88780fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
styled-components Patch

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
quantizor requested review from Copilot and removed request for Copilot May 14, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 forwardRef carrier detection; plain-object custom toString interpolation).
  • Improve TypeScript polymorphic as/forwardedAs behavior 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 componentStyle chain levels and entries in generatedClassName.split(' ') (it decrements nameIdx on every walk = walk.baseStyle). If an intermediate ComponentStyle layer has no CSS (e.g. styled(Base)```) but its base does, the next nameactually 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 current IS_RSC branch in StyledComponent.ts always returns a <style> tag whenever combined is 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.
@quantizor
quantizor merged commit 9945904 into 6.x May 14, 2026
7 checks passed
@quantizor
quantizor deleted the may-bugfixes-6.x branch May 14, 2026 18:23
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