Skip to content

Commit eaaab30

Browse files
Remove deprecated react-test-renderer type from published declarations (#9055)
## Summary Remove the `import type { ReactTestInstance } from 'react-test-renderer'` from `jestUtils/index.ts` and replace the parameter with a minimal structural type. `react-test-renderer` is [deprecated in React 19](https://react.dev/warnings/react-test-renderer), and `@testing-library/react-native` v14 [replaces it](https://oss.callstack.com/react-native-testing-library/14.x/docs/start/migration-v14) with the new [`test-renderer`](https://github.com/mdjastrzebski/test-renderer) package (and its `TestInstance` type). The `ReactTestInstance` type was only used as the `getAnimatedStyle` parameter, which immediately casts it away via `as unknown as TestComponent` — making it purely decorative. The structural replacement `{ props: Record<string, unknown> }` is compatible with both `ReactTestInstance` (RNTL v13) and `TestInstance` (RNTL v14) via TypeScript's structural typing — I verified both compile cleanly. No consumer code changes needed. **Before:** Published `jestUtils/index.d.ts` imports from `react-test-renderer`, which isn't in `dependencies` — breaks consumers with `skipLibCheck: false`. **After:** No external type import in `jestUtils`. Works for all consumers regardless of `skipLibCheck` setting. ## Test plan **Structural type compatibility** — tested with both `ReactTestInstance` (`@types/react-test-renderer@19.1.0`) and `TestInstance` (`test-renderer@0.15.0`). Both accepted by the structural type. Invalid inputs (missing `props`, wrong type, `null`) correctly rejected. **Consumer reproduction** — patched the published `lib/typescript/jestUtils/index.d.ts` in a consumer project with `skipLibCheck: false` and no `@types/react-test-renderer` installed. Before: `TS2307: Cannot find module 'react-test-renderer'`. After: gone. **Upstream quality gates:** ``` yarn workspace react-native-reanimated type:check:src:native ``` Zero regressions (same pre-existing `react-native-worklets` errors only).
1 parent 24241cc commit eaaab30

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • packages/react-native-reanimated/src/jestUtils

packages/react-native-reanimated/src/jestUtils/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
'use strict';
33

44
import type React from 'react';
5-
import type { ReactTestInstance } from 'react-test-renderer';
65

76
import { IS_JEST, logger, ReanimatedError } from '../common';
87
import type {
@@ -347,12 +346,10 @@ type TestComponent = React.Component<
347346
}
348347
>;
349348

350-
export const getAnimatedStyle = (component: ReactTestInstance) => {
351-
return getCurrentStyle(
352-
// This type assertion is needed to get type checking in the following
353-
// functions since `ReactTestInstance` has its `props` defined as `any`.
354-
component as unknown as TestComponent
355-
);
349+
export const getAnimatedStyle = (component: {
350+
props: Record<string, unknown>;
351+
}) => {
352+
return getCurrentStyle(component as unknown as TestComponent);
356353
};
357354

358355
export { worklet } from './common';

0 commit comments

Comments
 (0)