Skip to content

Commit adff581

Browse files
YevheniiKotyrlom-bert
authored andcommitted
Move @types/react-test-renderer to dependencies (#4015)
Move `@types/react-test-renderer` from `devDependencies` to `dependencies`. The published `lib/typescript/jestUtils/jestUtils.d.ts` imports `ReactTestInstance` from `react-test-renderer` (line 1). Since `@types/react-test-renderer` is only in `devDependencies`, it's not installed for consumers — causing `TS2307: Cannot find module 'react-test-renderer'` for projects with `skipLibCheck: false`. The [TypeScript handbook](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) is explicit: when published `.d.ts` files reference `@types/*` packages, those packages must be in `dependencies` so consumers resolve them automatically. Several major packages have fixed this exact pattern: - [webpack/schema-utils#97](webpack/schema-utils#97) — moved `@types/json-schema` to `dependencies` for the same reason - [@mui/material#14508](mui/material-ui#14508) — keeps `@types/react-transition-group` in `dependencies` because published types extend it - [react-native-testing-library#1534](callstack/react-native-testing-library#1534) — shipped `.d.ts` broke `skipLibCheck: false` consumers, fixed within 2 days This repo dealt with the same class of issue in #1990 (move `@types/react-native` to `dependencies` — closed only because RN 0.71+ bundled its own types, not because the approach was rejected) and #2259 (shipped `.d.ts` type errors). Note: `react-test-renderer` is [deprecated in React 19](https://react.dev/warnings/react-test-renderer). As more projects drop it from their own dependencies, this breakage will increase for downstream consumers. **Consumer reproduction:** ```bash mkdir test-rngh && cd test-rngh npm init -y npm install react react-native react-native-gesture-handler typescript @types/react ``` `tsconfig.json`: ```json { "compilerOptions": { "strict": true, "noEmit": true, "skipLibCheck": false, "moduleResolution": "bundler", "module": "esnext", "target": "esnext", "jsx": "react-jsx" }, "include": ["*.ts"] } ``` `repro.ts`: ```typescript import type { fireGestureHandler } from 'react-native-gesture-handler/lib/typescript/jestUtils/jestUtils'; export type { fireGestureHandler }; ``` ```bash npx tsc --noEmit npm install @types/react-test-renderer npx tsc --noEmit ``` **Upstream quality gates:** ```bash yarn workspace react-native-gesture-handler ts-check # PASS yarn workspace react-native-gesture-handler build # PASS — module + commonjs + typescript ``` Zero regressions.
1 parent 2aeb684 commit adff581

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/react-native-gesture-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"dependencies": {
7474
"@egjs/hammerjs": "^2.0.17",
7575
"hoist-non-react-statics": "^3.3.0",
76+
"@types/react-test-renderer": "^19.1.0",
7677
"invariant": "^2.2.4"
7778
},
7879
"devDependencies": {
@@ -85,7 +86,6 @@
8586
"@types/invariant": "^2.2.37",
8687
"@types/jest": "^27.0.3",
8788
"@types/react": "^19.2.0",
88-
"@types/react-test-renderer": "^19.1.0",
8989
"@typescript-eslint/eslint-plugin": "^6.9.0",
9090
"@typescript-eslint/parser": "^6.9.0",
9191
"babel-plugin-module-resolver": "^5.0.2",

0 commit comments

Comments
 (0)