fix: make Animated component instance types and type tests Strict API compatible#9960
Draft
tjzel wants to merge 1 commit into
Draft
fix: make Animated component instance types and type tests Strict API compatible#9960tjzel wants to merge 1 commit into
tjzel wants to merge 1 commit into
Conversation
tjzel
force-pushed
the
@tjzel/strict-api-typetests
branch
2 times, most recently
from
July 15, 2026 14:48
92f9940 to
c0482cb
Compare
tjzel
force-pushed
the
@tjzel/strict-api-typetests
branch
from
July 15, 2026 14:51
c0482cb to
1c19f27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR description is AI-generated.
Summary
Requires #9957
With module resolution fixed in #9957, the type tests run against the Strict API types that react-native nightlies serve by default since
0.88.0-nightly-20260711, which surfaced ~90 errors — #9957 pinned the tests to the legacy type surface with thereact-native-legacy-deep-importscondition as a stopgap. I removed the pin and made the types pass under both surfaces.Most failures were legacy-only patterns in the test files:
useRef<Image>usesImageas an instance type, which the Strict API no longer models (refs point to host instances likeReactNativeElement), andFlatListno longer acceptsrenderItem={null}. I replaced instance generics withComponentRef<typeof Image>, which resolves to the correct instance type under either surface and is the migration path recommended in https://reactnative.dev/docs/strict-typescript-api, andnullrender items with() => null. A few@ts-expect-errorassertions held only under legacy types — stringwidth,shadowOffsetwithoutheightand numeric colors are all legal under the Strict API — so I changed them to values that are illegal under both.The one real problem in Reanimated's types was the
Animated.View/Animated.Text/Animated.Image/Animated.ScrollViewinstance aliases, which extend the legacy component classes (interface AnimatedViewComplement extends View). I redefined them withComponentRef<typeof View>, souseRef<Animated.View>resolves to the class instance under legacy types and to the host element under the Strict API.Test plan
All five compatibility-check steps (
type:check:src:native,src:web,plugin,app,tests) pass on bothreact-native@0.86.0andreact-native@0.88.0-nightly-20260714-a016e94b5, as doesreact-native-workletstype:check:tests.