Repository navigation
fix(native): avoid TS2590 error on Reanimated refs after a styled component (#5879) - #5889
Conversation
🦋 Changeset detectedLatest commit: ab9086d 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.
ℹ️ Minor suggestions only.
Approach: sound — replacing the JSX.IntrinsicElements['div'] probe with keyed ClassAttributes/HTMLAttributes keeps detection identical for the two documented augmentation sites (their key sets are the same union) while removing the evaluation that exhausted TS's union budget at Reanimated refs.
Reviewed changes
- Probe narrowing —
IntrinsicElementsHaveDataIndexnow keysReact.ClassAttributes<HTMLElement> | React.HTMLAttributes<HTMLElement>, which is key-for-key equivalent to the oldIntrinsicElements['div']intersection but never expands the intrinsic element map. - New regression project —
test-types/attributes-index-signature.tsxplus its tsconfig pins theReact.Attributes/ClassAttributeshalf of the probe and mirrors the existingReact.HTMLAttributesfixture. I confirmed it fails with TS2590 if that branch is dropped, and passes if the probe reverts to the old expression (matching what the docs state). - Wiring and docs —
test:types,check:type-resolution,knip.jsonc,docs/typescript-performance.md, and the patch changeset are all updated; the full type gate,check:type-resolution,knip, and Biome pass.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: the commit since the prior pullfrog review is documentation-only, and it resolves the one prior nit.
- Fixture rationale documented — the header of
attributes-index-signature.tsxnow records why its project setsjsx: react-jsx: theReact.Attributesaugmentation reachesJSX.IntrinsicAttributes, so classicjsx: reactfails with TS2322 on fragments in importedsrc/files. I re-confirmed this by flipping the tsconfig tojsx: reactand reproducing the two errors atStyleSheetManager.tsx:297and:301; the project passes as committed.
ℹ️ GitHub took this as a comment because it requires explicit repository access to approve or block a pull request here.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Forward-ports #5879 to
main(v7).Impact
Apps using
styled-components/nativealongside Reanimated'suseAnimatedRefno longer hit TS2590 ("Expression produces a union type that is too complex to represent") when TypeScript checks a native styled component before the ref. If a DOM element or web styled component is checked earlier in the same program, TypeScript can still report TS2590, as it does for a plain<div>without styled-components.Changes
IntrinsicElementsHaveDataIndexinpackages/styled-components/src/types.tsto probekeyof React.ClassAttributes<HTMLElement> | keyof React.HTMLAttributes<HTMLElement>instead ofkeyof React.JSX.IntrinsicElements['div'].test-types/attributes-index-signature.tsxandtsconfig.test-attributes-index.json(wired intotest:types,check:type-resolution, andknip.jsonc) pinning theReact.Attributesdata-*index augmentation contract.docs/typescript-performance.mdand add.changeset/native-animated-ref-ts2590.md.