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
Commit 4eaf66b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(native): avoid TS2590 error on Reanimated refs after a styled component (#5879)
fix(native): prevent TS2590 on Reanimated refs after a styled component
The data-* probe added by #5797 uses keyof
React.JSX.IntrinsicElements['div']. A React Native app using a styled
component will evaluate the probe, and with Reanimated's useAnimatedRef
in the code, that will cause TypeScript to show the TS2590 error on the
ref (#5877). The probe is now using keyof on each part of the props
(ClassAttributes and HTMLAttributes) separately, not on their
intersection, which means the same keys are being used. However,
checking a DOM tag or web styled.div before the ref will still result
in the TS2590 error being shown, as with a normal <div> without
styled-components.
The new type test will use a data-* index on React.Attributes for
checking the ClassAttributes part. This will fail with TS2590 when
using the probe on HTMLAttributes only. However, this passes on 6.x as
well. In-tree tests cannot fail on 6.x as the trigger requires the
React Native and Reanimated types, so #5877 has been added to the
out-of-tree list in docs/type-contracts.md.
Only the emitted .d.ts files have changed. The built JS is byte for
byte identical. These checks passed: test:types, typecheck,
prettier:check, test:types:dist, check:type-resolution. type-perf
(36,886 types, 738,335 instantiations) and type-perf:augment (37,045
types, 812,680 instantiations) also match 6.x (TypeScript version
5.9.3, @types/react version 18.3.28). test:web and test:native were
not run. test:build failed 8/36 on Windows for both base and branch
due to the backslashes being removed from the entry path by webpack.
A `styled-components/native` component will no longer cause TypeScript to show an error of TS2590 ("Expression produces a union type that is too complex to represent") on a Reanimated `useAnimatedRef` ref, which it did from 6.5.3. However, if a DOM element or web styled component is checked earlier in the code then this error can still show, like a normal `<div>` would without styled-components.
0 commit comments