Repository navigation
feat(types): derive target props once per target, and merge a declared style type - #5784
Conversation
🦋 Changeset detectedLatest commit: bccfb1f 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 |
There was a problem hiding this comment.
Pull request overview
This PR reduces TypeScript type-check cost for styled-components consumers by moving style prop widening (CSS custom properties support) from per-JSX-call-site evaluation to a one-time, per-render-target derivation (TargetProps), and updates the type-performance budget + type contract suite accordingly.
Changes:
- Apply
OverrideStyleat the render-target level via exportedTargetProps<T>and remove the per-call-siteOverrideStyleapplication in polymorphic call props. - Update web/native constructor typings to derive outer props via
TargetPropsso the widening happens once per target. - Tighten the type-perf budget and add new type contract cases covering the new
style-override behavior and extractedstyletyping.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/styled-components/type-perf.budget.json | Updates the type-perf thresholds to the new baseline. |
| packages/styled-components/src/types.ts | Moves style widening into TargetProps, adjusts Attrs and related helper types for the new flow. |
| packages/styled-components/src/test/types.tsx | Adds type contract cases for style override behavior, extraction visibility, and style={undefined}. |
| packages/styled-components/src/native/index.ts | Updates RN component prop derivation to use TargetProps. |
| packages/styled-components/src/constructors/styled.tsx | Derives web constructor outer props via TargetProps instead of conditional ComponentPropsWithRef. |
| packages/styled-components/src/constructors/constructWithOptions.ts | Uses TargetProps in attrs target resolution and as the default OuterProps. |
| AGENTS.md | Documents the measured, load-bearing type-shape constraints for future maintenance. |
| .changeset/wild-hoops-shake.md | Updates release type to minor and refreshes consumer-facing perf numbers. |
| .changeset/proud-mangos-argue.md | Adds a consumer-facing note about the style prop type override behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The style widening moves from the merged prop bag at every JSX call site
into TargetProps, where a render target's prop interface is derived. A
target's props are shared by every component built on it, so the Omit
resolves once per tag instead of once per component.
On a 500-component fixture measured against the built declarations,
check time drops by about 40% and types by about 80% relative to the
previous commit. Against 6.4.4 that is roughly 4.5x faster and about a
third of the memory, and it now runs ahead of 6.4.2 on types,
instantiations and check time alike.
Four details are load-bearing, each found by measurement:
- The style test is `'style' extends keyof P`, not
`P extends { style?: infer S }`. The latter is vacuously satisfied by
`{}`, which would give un-introspectable targets a style key and defeat
WidenUntypedProps (#5756).
- Attrs no longer re-applies the widening. Its Props already carry it,
and re-applying stopped Attrs<any> relating to Attrs<OuterProps>.
- The explicit `| undefined` keeps style={undefined} assignable under
exactOptionalPropertyTypes.
- Substitute's second parameter is now unbounded. Bounding it to
BaseObject forces callers to write `TargetProps<T> & BaseObject`, and
`{}` is retained rather than reduced inside an intersection, so the
bound propagates an unreducible node through every downstream prop
bag, costing roughly +160% types and +70% check time on its own.
Because the widening now runs before user props are substituted in, a
`style` type declared on the component replaces it rather than being
unioned with it, and prop extraction reports the widening it previously
hid. Both are pinned by new contract tests.
0ba6b45 to
45b0a2c
Compare
The guard was `keyof K extends never`, but `K` is the set of attrs keys and is `never` for any component without `.attrs()`. `keyof never` is `string | number | symbol`, so the short-circuit never fired: every such component instantiated an omit plus a `Partial<Pick<...>>` that removed and re-added nothing, and intersected the empty object into its own props, which never reduces. Present since well before this branch. Removing it drops instantiations by about 15% and check time by about 10% on top of the rest, and roughly halves the length of the type shown on hover.
# Conflicts: # packages/styled-components/type-perf.budget.json
A conditional type alias loses its name the moment it resolves: the
checker returns the branch type and drops the aliasSymbol, so an inlined
branch prints its full expansion in every hover, error and quick-info.
Naming the branches (WithCSSVars, IntrinsicProps, ComponentTargetProps,
Substituted) gives the checker something to print. A styled button's
type goes from roughly 380 characters of nested FastOmit, Omit and
inline object literals to:
IStyledComponentBase<"web", Substituted<IntrinsicProps<"button">,
{ foo: boolean; }>> & string
The intrinsic branch applies the widening directly instead of routing
through OverrideStyle, since every intrinsic element declares `style`
and the guard has nothing to decide there.
Structural only. Types and instantiations move by well under a tenth of
a percent, and check time is unchanged.
The budget could not see the regression class it exists to catch, and one of its own flags silently measured the wrong thing. - `--count=500` never matched, because the flag was parsed with indexOf against a bare `--count`. That spelling measured the default 100 and reported success. Now on util.parseArgs, which also rejects unknown and valueless flags rather than ignoring them. - Budget memory alongside types and instantiations. Against one fixture 6.4.4 records fewer instantiations than 6.4.3 while using ~190MB more, so a counters-only budget reads that regression as an improvement. Tolerances now come from measured run-to-run noise (counters are bit-identical, memory moves ~1%) and the V8 heap is pinned so a slower CI runner measures the same figures. - Store the measured values plus a tolerance rather than bare ceilings, so an improvement is reported instead of silently becoming slack. - Record the typescript and @types/react versions and warn on drift, since a dependency bump moves every figure on its own. - Add a canary to the fixture. skipLibCheck hides a dist whose own declarations cannot resolve their dependencies: every export degrades to `any`, the fixture still compiles, and the run reports a large fake win. The canary's @ts-expect-error directives stop firing in that state, which the clean-compile gate catches. - Cover the native entry and spread/generic call sites, and refuse to measure against a dist older than src. - One tsc invocation instead of two; --extendedDiagnostics already prints the error lines the first pass was spawned to collect. Also drops a dead React import left behind when styled.tsx moved to TargetProps.
Declaring `styled.div<{ style?: { width: number } }>` previously had no
effect, because the CSS-variable widening was applied after the
component's own props. Widening at the target fixed that but swung too
far: the declaration replaced the whole type, so constraining one field
lost every field the author had not mentioned.
The merge is the intersection that falls out of not omitting `style`
from the target, so `CSSPropertiesWithVars & { width: number }`
constrains width and keeps the rest. Both conditional spellings were
tried and measured first: testing `keyof A` tips tsc into TS2590
outright, and testing `keyof B` costs +54% types because it stays
deferred while B is generic and the checker materializes both branches.
The intersection costs +0.006%.
Full override stays expressible: a field declared `never` is ablated,
and the new exported CustomStyle<T> ablates everything a declaration
does not name, so nobody hand-writes `?: never` for 265 properties.
Also fixes a TS2589 in chained `.attrs()` that this branch introduced
against both 6.4.2 and 6.4.4. The `.attrs()` seam resolves its target
through ComponentPropsWithRef rather than TargetProps: a function-form
`.attrs(({ as }) => ({ as: as || 'button' }))` makes that target a
union, and TargetProps is two conditionals, so it distributes inside a
distribution. Measured on a three-line repro, 6.4.2 cost 157K
instantiations and TargetProps cost 6.9M, tipping into TS2589 with one
more chained layer; ComponentPropsWithRef lands it at 133K. It is
merged rather than substituted there so the widening survives.
Found by an adversarial battery built from 41 reported type issues,
compiled against 6.4.2, 6.4.4 and this branch on @types/react 18 and
19. Zero regressions and zero pinned-behavior drift across the set.
…p bag
Wrapping a target whose props cannot be introspected (Mantine's
polymorphic-factory components, and anything else whose resolved props
are `{}`) makes the styled component permissive, so the target's own
props and `children` keep working. Adding a prop of your own switched
that off:
styled(PolyButton)<{ $variant: 'a' | 'b' }>``
`WidenUntypedProps` asks whether the finished prop bag is empty, and a
transient prop gives it a `keyof` of `'$variant'`, so the widening
stopped applying and `children` started being rejected. Whether a target
can be introspected is a property of the target, not of what the
component layers on top, so the test now runs against the target.
Applying it over an already-widened bag is a no-op: the index signature
makes `keyof` be `string`, so the second check is false.
Reported in #5756 and still present on 6.4.2 and 6.4.4. Found by the
adversarial battery, which had it as the one case failing identically
everywhere rather than as a regression.
`RuleSet<Props>` is defined as `Interpolation<Props>[]`, so listing both `RuleSet<Props>` and `Interpolation<Props>[]` in the union spelled the same recursive branch twice and doubled the work of expanding it. Keeping the named alias, which also reads better in hovers. Found while investigating #3496, where `css?: CSSProp` plus a library with deep recursive generics of its own trips the instantiation-depth limit. The dedupe does not fix that on its own and no shallower `CSSProp` is worth having: every variant that clears it also stops `css={cssHelperOutput}` being assignable, which is the primary use of the prop. The limitation reproduces identically on 6.4.2 and 6.4.4, so it is standing rather than new; AGENTS.md records the ablation so it is not re-litigated.
…straints through `as` Two gaps a full review found, both in code this branch introduced. Permissiveness for an un-introspectable target was tested against the merged prop bag rather than the target. Those coincide until `.attrs()`, after which the bag has absorbed the component's own props, its `keyof` stops being `never`, and the widening switches off -- #5756 one layer down. Now tested against `TargetProps<Target>`, which is that parameter's own default, so it costs no new instantiation. `WidenUntypedProps` collapses into `WidenForUntypedTarget<P, P>`; the two were identical apart from which parameter they tested. `CustomStyle` promises its type is the only one accepted, and a declared `style` promises the fields it names are constrained. Both were escapable by rendering through `as` or `forwardedAs`, because `PolymorphicComponentProps` substituted the render target's props over the component's own and substitution replaces `style` outright. It merges now. This is the one place a per-JSX-site cost was accepted rather than moved off the call path, so it was measured first: +0.016% types, +0.48% instantiations, memory unchanged. Known limitation, documented on the type and in the changeset rather than paid for: under `exactOptionalPropertyTypes` the intersection leaves no `undefined` arm, so a component declaring its own `style` rejects an explicit `style={undefined}`. Omitting the prop is unaffected and `style?: X | undefined` restores it. Every automatic fix needs a conditional in `MergeProps`, and that shape measured +54% types. Also: names `MergeProps`'s taken branch so hovers print a name instead of an expansion compounding once per extension link; aligns the `.attrs()` implementation with its interface, which spelled the same position differently while the comment explaining the correct spelling sat only on one; and adds `--expose-gc` to the type-perf run, since tsc collects before sampling memory only when `global.gc` exists and every figure banked before this was a pre-GC snapshot including garbage. Memory is now bit-identical across runs. A per-metric presence check closes a hole where a metric absent from the budget file produced NaN bounds and reported "within budget" while checking nothing.
Ports 29 cases from an adversarial battery built out of reported type
issues, using hand-written stubs rather than new dependencies.
Web: ref-callback inference, the interpolation parameter not widening to
`any`, attrs with a union prop and no `as const`, custom-element `as`
targets, event-handler and function-prop inference, prop extraction
through ReturnType, chained `.attrs({ as })`, custom properties in nested
object styles, computed-key selectors, withTheme, the v5-to-v6 alias
renames, and pins for the documented limitations.
Native: the package had no native type coverage at all, so a native-only
regression was invisible to the unit suites and the type check alike.
Covers `ref` on shorthand components including an unannotated ref
callback, attrs with a required prop, declared props reaching
interpolations, and the shorthand surface.
Four reported issues stay out of tree: antd, react-bootstrap 2.8,
react-spring and preact/compat are each a union-explosion or
recursion-depth cliff, and a simplified stub sits clear of the cliff and
passes for the wrong reason. Verified out of tree against the real
packages at the versions reported; AGENTS.md records which and when to
re-check.
The chained-attrs assertion was vacuous as first written: the function
form types the resolved target as the whole target union, which is
un-introspectable, so the permissive fallback accepted the prop being
asserted and would have accepted anything. Moved to the object form with
three controls.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/styled-components/src/types.ts:472
TargetProps/OverrideStyleapplies the CSS-variablestylewidening to any component target. SinceTargetPropsis also used by the React Native entry (styled-components/native), this makes native componentstyleprops acceptCSSPropertiesWithVars(including--*custom properties and web-only CSS keys), which is not valid for React Native styles and will silently accept invalidstyleobjects.
Consider narrowing the widening to targets whose style prop is actually a web CSSProperties shape, so native targets keep their original StyleProp<...> typing.
type OverrideStyle<P extends BaseObject> = 'style' extends keyof P ? WithCSSVars<P> : P;
A native `style` accepts web-only CSS (`float`, `'3em'`, custom properties), because `TargetProps` carries no runtime parameter and so cannot gate the CSS-variable widening on web vs native where it applies. Verified identical on 6.4.2, 6.4.4 and current with a firing control in every column, so this is inherited rather than introduced here. Closing it means threading the runtime through `TargetProps` and its call sites, which is a signature change to measure rather than a patch. Raised as a suppressed comment on the PR review, which carries no comment id and would otherwise be unfindable. Pinned so that if the gap ever closes, the docs saying it is open get found.
TargetProps takes R as its first parameter and only ComponentTargetProps consults it, since NativeTarget is AnyComponent and the intrinsic arm is unreachable on native. R is deliberately undefaulted: a default is what would let a future native call site pick web CSS up by omission. The conditional distributes over Runtime, two members and concrete at every entry point, so it costs +0.55% instantiations and +0.05% types with memory flat -- not the ~4x a conditional over the target union costs. styled.View accepted `float` and custom properties on 6.4.2 through 6.4.4 alike; both are now pinned as @ts-expect-error in the native contract suite. `width: '3em'` stays accepted and is not ours: @types/react-native 0.71 types FlexStyle['width'] as `number | string`. The prior characterization block cited it as evidence of this library's widening, which it never was. Claude-Session: https://claude.ai/code/session_01PSMbXaMtE84Gzk7ebfjBuK
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/styled-components/src/types.ts:369
- Doc comment still refers to the old
TargetProps<Target>type alias, butTargetPropsnow takes a runtime parameter (TargetProps<R, T>). This makes the guidance misleading when someone tries to follow it or grep for the referenced form.
* call site here passes `TargetProps<Target>` for that reason.
Three comments still spelled the pre-runtime-gate signature. Copilot flagged the one in types.ts; a repo-wide sweep for the same mistake found two more in AGENTS.md, one of which described the distribution rule in a way that now reads as forbidding the R gate. Claude-Session: https://claude.ai/code/session_01PSMbXaMtE84Gzk7ebfjBuK
Verified mechanically rather than by reading, each with a control: - docs/rendering-flow.md named buildClassName and rawElement, neither of which exists. The diagram also claimed a React.createElement bypass; `git log -S rawElement` finds nothing and every $$typeof use is type detection, so that optimization is not on this branch. Replaced with buildPropsForElement plus React's own createElement, and the AGENTS.md perf row now says the raw-element form is a measurement, not an inventory entry. - The cast in styled.tsx was said to avoid "120" Styled<> instantiations in two places; domElements has 153 entries. Restated per-element so it cannot drift again. - AGENTS.md documented `pnpm run generateErrors`, which fails from the repo root. Every other command there is --filter scoped. - PolymorphicCallProps' comment still described substituting the `as` target's props, contradicting AGENTS.md, which records that they merge. - The repo-root src/utils/errors.md was described as kept in sync. It is read by nothing, stops at error 13, and its entry 2 describes a different error than the one shipped. Documented as a frozen stub; whether it should exist is left to the maintainer. - The three-term server check has one deliberate two-term exception in createGlobalStyle, now recorded so nobody relaxes the rule elsewhere. Also enables noUnusedLocals, which is what would have caught the stale Substitute import removed here. Contract suites opt out: a compile-only type test declares things to be checked, not read. Claude-Session: https://claude.ai/code/session_01PSMbXaMtE84Gzk7ebfjBuK
… sequence (#5789) * docs: split AGENTS.md into specifications under docs/ AGENTS.md had grown to carry both the rules and the full specification of every subsystem, so the rules were hard to find and the specifications drifted unread. It now holds the rules and a map; each subject has one home under docs/. Tracing the moved text against the source turned up several claims that no longer described 6.x: - keyframes were documented as emitted in a dedicated <style> tag that component CSS must never be prepended to. 6.x concatenates them into one tag, and the cited getEmittedCSS does not exist on this branch. - stylisPluginRSC was documented as rewriting child-index selectors. It also expands adjacent sibling combinators, with its own limitations. - IS_BROWSER checks document as well as window. - nonce was documented as inherited by a nested StyleSheetManager. It is a sheet option resolved by getNonce, and is not part of the RSC context override. - createTheme's contract omitted GlobalStyle, without which nothing is emitted. - the stylis AST caveat said props "can alias" between a rule and its nested copy. The parser hands the nested ruleset the parent's array outright, which is now stated with the reproduction. CLAUDE.md was a real symlink to AGENTS.md and is now a pointer file, so writing either name cannot clobber the other. * fix(types): keep union props through styled(), and stabilize the hook sequence Three fixes plus the guardrails that keep each from recurring. `OverrideStyle` lost its distribution over unions when #5784 moved the test from a naked `P extends { style?: infer S }` to `'style' extends keyof P`. `keyof` a union is the keys common to every member, so an undistributed pass rebuilt `A | B` from the shared keys alone and dropped every member-specific prop. Restored with an outer `P extends unknown`. Fixes #5787. The same class, found while auditing the siblings: `Substitute` and `MergeProps` recognize an empty prop bag with `keyof B extends never`, which a union of disjoint shapes also satisfies, so such a union was dropped wholesale. Now discriminated with `{} extends B`. Predates 6.5.0. A per-member re-ask is the more complete fix and tips tsc into TS2589 against a caller spreading `as?: WebTarget`; the accepted limitation, an all-optional disjoint union, is pinned in the contract suite. At runtime, `useDebugValue` sat inside the render cache's miss branch and was skipped whenever props were unchanged. Moved past the if/else. The `use`-prefixed `useInjectedStyle` wrapper it lived in called no hooks of its own and is inlined, removing the seam that made a conditional call look safe. Guardrails: contract-suite cases for every union surface, each accepted prop paired with a rejected one so a widening cannot fake a pass; a runtime test asserting the hook sequence is identical across cache hit and miss; and a `unionTarget` kind in the consumer type-check fixture, which prices the distributive path and, because the run fails on any fixture compile error, fails outright if the union collapses again. Consumer type-check cost: +0.04% instantiations, types and memory flat. The recorded budget moved because the fixture grew, not because the cost did. * chore: address review feedback Reset the hook recorder's buffer in a finally so a throwing render cannot leave it live for the next one. Drop the hard-coded instantiation counts from the type-performance doc and point at the budget file and its command instead, per the project's rule against restating drift-prone numbers. Rewrite both changesets in terms of what a consumer observes rather than the type expressions involved.
Stacked on #5783. Merging that one first retargets this to
6.xautomatically.#5783 gets type-check cost back under 6.4.2 on instantiations but leaves it above on types and memory. This closes the rest and then some: every headline number is now better than 6.4.2, so there is no longer a reason for anyone to stay pinned there.
The change is to stop widening the
styleprop on the merged prop bag at every JSX call site, and instead widen it once where a render target's props are derived. A target's prop interface is shared by every component built on it, so the work resolves once per tag rather than once per component per call site.Measured against the built declarations, median of repeated cold runs, TypeScript 5.9.3. Ratios rather than absolute figures so they do not rot.
500 components
Against 6.4.2 specifically, that is roughly a quarter fewer types, a sixth fewer instantiations and a sixth less check time. Against 6.4.4 it is a bit over 4.5x faster. The same holds at 100 components and under
@types/react19.The behavior change, and why this is a minor
Because the widening now happens before your props are substituted in rather than after, a
styletype you declare yourself takes effect. It constrains the fields you name and leaves the rest of CSS alone:Previously the built-in style type was appended after your declaration, so a component that said it only accepted
{ width: number }still accepted any CSS value forwidth. Now the declaration is honoured, without costing you every property you did not mention.Two escape hatches, because sometimes replacing really is the point. Declaring a field as
neverremoves it, and the newCustomStylehelper removes everything a declaration does not name, so nobody writes?: never265 times:The constraint holds when the component is rendered through
asorforwardedAs, so it cannot be sidestepped by rendering the same component as a different tag.CustomStyleremoves CSS custom properties too, since they are among the fields you did not list.One limitation, documented rather than papered over: under
exactOptionalPropertyTypes, a component that declares its ownstylerejects an explicitstyle={undefined}. Leaving the prop off is unaffected, and writingstyle?: { width: number } | undefinedrestores it. Every automatic fix needs a conditional in the merge, and that shape measured a 54% increase in types, so the cost was not worth paying. It is characterized in the contract suite, so if it ever stops being true the docs saying otherwise get found.Relatedly, reading the style type back off a component (
React.ComponentProps<typeof Box>['style']) now reports that CSS custom properties are accepted. That was already true when rendering; the extracted type just did not say so.React Native
styleis now checked against React Native's own typesThe CSS-variable widening is a web concern, but until now it reached native components too, so a
Viewaccepted web CSS that React Native has never done anything with at runtime:Both of those compiled on 6.4.2, 6.4.3 and 6.4.4 alike, so this is inherited rather than introduced by the rework, but this branch is where the seam that could carry the runtime came into being, so it is fixed here. The widening is now gated on the runtime, which is why this is the second reason the PR is a minor rather than a patch: native code that was passing web CSS will start seeing type errors where it previously saw silence.
Note that
style={{ width: '3em' }}is still accepted, and that one is not ours.@types/react-nativetypesFlexStyle['width']asnumber | stringat the version pinned here, so a web length passes React Native's own definitions. If a react-native bump tightens that, the contract suite says so.Verification
An adversarial battery was built from 41 type problems reported on this tracker, each case using the reporter's own reproduction, compiled against 6.4.2, 6.4.4 and this branch under both
@types/react18 and 19. Nothing is stubbed and nothing is skipped: the cases that needantd,[email protected],react-spring,preactandreact-nativerun against those packages at the versions the issues were reported on, because the failures in question are union-explosion and recursion cliffs that a simplified stub sits comfortably clear of and would pass vacuously.Zero regressions against a passing baseline, and zero drift on the cases pinned to document existing behavior, across 234 compiled case/variant/React-major combinations. One case is not from the tracker: it pins the native
stylebehavior above, and is the one place the branch deliberately differs from 6.4.2, reporting exactly the two rejections and leaving valid native styles alone.It earned its keep. It caught this branch introducing a hard failure in chained
.attrs()where both 6.4.2 and 6.4.4 compiled fine, on a shape the docs themselves recommend:That is fixed here, and now costs less than 6.4.2 does on the same code.
It also isolated a bug that was failing identically on 6.4.2, 6.4.4 and this branch, rather than as a regression, so nothing else had flagged it. Wrapping a target whose props cannot be inspected (Mantine's polymorphic components are the reported case) makes the styled component permissive so the target's own props keep working, but adding a prop of your own switched that off and
childrenstarted being rejected:That closes the remaining half of #5756. Two further long-standing reports turn out to be fixed as a side effect:
refon React Native shorthand components such asstyled.TextInput(#4143), and anattrscallback given an explicit parameter type (#4088), which is the workaround the maintainers had been recommending.One standing limitation is now pinned rather than left unexamined:
css?: CSSPropcombined with react-spring's recursiveanimatedtypes trips the instantiation-depth limit (#3496). It reproduces identically on 6.4.2 and 6.4.4, so it is not new here, and it is ours rather than react-spring's. Every shallower spelling ofCSSPropthat clears it also stopscss={cssHelperOutput}being assignable, which is the main way the prop is used, so the recursion stays and the battery will notice if that ever changes.Also:
@ts-expect-errorwas added or removed.skipLibCheckhides it.Contract coverage
29 cases from the battery are now permanent contract tests, using hand-written stubs rather than new dependencies. The native entry gets its first type suite at all: it previously had none, so a native-only type regression was invisible to both the unit suites and the type check.
Notes for review
The load-bearing details are written up in AGENTS.md so they are not undone later. Two worth flagging here:
Substitute's second type parameter is unbounded. Bounding it forces callers to intersect& {}to satisfy it, and{}is retained rather than reduced inside an intersection, so that single bound propagated an unreducible node through every downstream prop bag.The
.attrs()seam deliberately does not use the same target-props helper as everywhere else. A function-formasmakes its target a union, and that helper is two conditionals, so it distributes inside a distribution. Cheaper in count, deeper in nesting, and the nesting is what fails.