Closed
Conversation
Member
Author
|
Since 0.71 types are bundled with React Native. |
j-piasecki
pushed a commit
that referenced
this pull request
Mar 5, 2026
## Summary 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. ## Test plan **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 # Error: Cannot find module 'react-test-renderer' or its corresponding type declarations. # At: node_modules/react-native-gesture-handler/lib/typescript/jestUtils/jestUtils.d.ts(1,35) npm install @types/react-test-renderer npx tsc --noEmit # Clean — zero errors ``` **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.
m-bert
pushed a commit
that referenced
this pull request
Apr 2, 2026
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.
Copilot AI
pushed a commit
that referenced
this pull request
Apr 2, 2026
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. Co-authored-by: m-bert <63123542+m-bert@users.noreply.github.com>
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.
Description
Moves
@types/react-nativeto dependencies from devDependencies.Fixes #1720.