You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TS2590 "union type too complex" in React Native projects using Reanimated since 6.5.3 #5877
Since 6.5.3, tsc fails with TS2590 in our React Native app, at code that uses a Reanimated animated ref:
src/components/TabBar/TabBar.tsx(158,5): error TS2590: Expression produces a union type that is too complex to represent.
Line 158 is a plain useCallback dependency array, [ref, tabs.length], where ref = useAnimatedRef<Animated.ScrollView>().
Versions: styled-components 6.5.3 and 6.6.0 fail; 6.4.4 through 6.5.2 pass. react-native-reanimated 4.5.1, react-native 0.86.3, React 19.2.3, @types/react 19.2.17 (single copy), TypeScript 5.9.3. We import from styled-components/native, and React.HTMLAttributes is not augmented with a data-* index signature.
Editing 6.5.3's types.d.ts so that IntrinsicProps always uses WithCSSVars, or always uses WithCSSVarsForDataIndex, makes the error go away. So does replacing the probe with type IntrinsicElementsHaveDataIndex = false;. Neither props shape fails by itself; evaluating the probe does.
A --generateTrace shows the time going into measuring the variance of Reanimated's AnimatedRef (its ExtractElementRef checks TRef extends ElementType and ComponentRef<TRef>).
Where the error is reported depends on check order. Working around it in TabBar.tsx moves it to another file's useCallback dependency array that contains a useAnimatedRef<Animated.FlatList<Item>>() ref, with no styled component involved. Adding a file that calls useAnimatedRef<Animated.ScrollView>() early in the program makes the error disappear entirely.
We don't have a standalone repro yet and will add one if we can narrow it down.
npm install --ignore-scripts
npx tsc -p .
src/useScroll.ts(12,6): error TS2590: Expression produces a union type that is too complex to represent.
Results on this repro:
Change
TS2590
styled-components 6.5.3 (as above)
yes
styled-components 6.5.2
no
6.5.3 with type IntrinsicElementsHaveDataIndex = false; in its types.d.ts
no
6.5.3, StyledText defined but never rendered
no
6.5.3, Text.tsx renamed to zText.tsx so it's checked after useScroll.ts
no
So the error needs a native styled component to be rendered somewhere earlier in the program, before AnimatedRef's variance is measured. The two files don't import each other; the failing line is just useScroll.ts's dependency array.
Activity
pullfrog commentedon Nov 13, 2026
mljlynch commentedon Nov 13, 2026
Here's a standalone repro: four files, no app code.
package.json{ "name": "sc-ts2590-repro", "private": true, "scripts": { "typecheck": "tsc -p ." }, "dependencies": { "react": "19.2.3", "react-native": "0.86.3", "react-native-reanimated": "4.5.1", "react-native-worklets": "0.10.1", "styled-components": "6.5.3" }, "devDependencies": { "@types/react": "19.2.17", "typescript": "5.9.3" } }tsconfig.json{ "compilerOptions": { "target": "esnext", "module": "esnext", "lib": ["es2022"], "jsx": "react-jsx", "noEmit": true, "strict": true, "moduleResolution": "bundler", "customConditions": ["react-native"], "skipLibCheck": true }, "include": ["src"] }src/Text.tsxsrc/useScroll.tsResults on this repro:
type IntrinsicElementsHaveDataIndex = false;in itstypes.d.tsStyledTextdefined but never renderedText.tsxrenamed tozText.tsxso it's checked afteruseScroll.tsSo the error needs a native styled component to be rendered somewhere earlier in the program, before
AnimatedRef's variance is measured. The two files don't import each other; the failing line is justuseScroll.ts's dependency array.fix(native): avoid TS2590 error on Reanimated refs after a styled com…
quantizor commentedon Nov 25, 2026
Released in 6.7