Skip to content

fix: make Animated component instance types and type tests Strict API compatible#9960

Draft
tjzel wants to merge 1 commit into
mainfrom
@tjzel/strict-api-typetests
Draft

fix: make Animated component instance types and type tests Strict API compatible#9960
tjzel wants to merge 1 commit into
mainfrom
@tjzel/strict-api-typetests

Conversation

@tjzel

@tjzel tjzel commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

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 the react-native-legacy-deep-imports condition 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> uses Image as an instance type, which the Strict API no longer models (refs point to host instances like ReactNativeElement), and FlatList no longer accepts renderItem={null}. I replaced instance generics with ComponentRef<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, and null render items with () => null. A few @ts-expect-error assertions held only under legacy types — string width, shadowOffset without height and 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.ScrollView instance aliases, which extend the legacy component classes (interface AnimatedViewComplement extends View). I redefined them with ComponentRef<typeof View>, so useRef<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 both react-native@0.86.0 and react-native@0.88.0-nightly-20260714-a016e94b5, as does react-native-worklets type:check:tests.

@tjzel
tjzel force-pushed the @tjzel/strict-api-typetests branch 2 times, most recently from 92f9940 to c0482cb Compare July 15, 2026 14:48
@tjzel
tjzel force-pushed the @tjzel/strict-api-typetests branch from c0482cb to 1c19f27 Compare July 15, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant