Skip to content

Move @types/react-test-renderer to dependencies#4015

Merged
j-piasecki merged 1 commit intosoftware-mansion:mainfrom
YevheniiKotyrlo:fix/move-types-react-test-renderer-to-dependencies
Mar 5, 2026
Merged

Move @types/react-test-renderer to dependencies#4015
j-piasecki merged 1 commit intosoftware-mansion:mainfrom
YevheniiKotyrlo:fix/move-types-react-test-renderer-to-dependencies

Conversation

@YevheniiKotyrlo
Copy link
Copy Markdown
Contributor

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 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:

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. As more projects drop it from their own dependencies, this breakage will increase for downstream consumers.

Test plan

Consumer reproduction:

mkdir test-rngh && cd test-rngh
npm init -y
npm install react react-native react-native-gesture-handler typescript @types/react

tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "skipLibCheck": false,
    "moduleResolution": "bundler",
    "module": "esnext",
    "target": "esnext",
    "jsx": "react-jsx"
  },
  "include": ["*.ts"]
}

repro.ts:

import type { fireGestureHandler } from 'react-native-gesture-handler/lib/typescript/jestUtils/jestUtils';
export type { fireGestureHandler };
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:

yarn workspace react-native-gesture-handler ts-check  # PASS
yarn workspace react-native-gesture-handler build      # PASS — module + commonjs + typescript

Zero regressions.

Copilot AI review requested due to automatic review settings March 4, 2026 11:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the published dependency graph for react-native-gesture-handler so downstream TypeScript consumers can resolve types referenced by shipped .d.ts files (notably in jestUtils) without needing manual installs.

Changes:

  • Move @types/react-test-renderer from devDependencies to dependencies to ensure it’s installed for library consumers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Member

@j-piasecki j-piasecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out!

@j-piasecki j-piasecki merged commit edef276 into software-mansion:main Mar 5, 2026
5 of 6 checks passed
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>
m-bert added a commit that referenced this pull request Apr 2, 2026
## Description

Cherry pick thread for release 2.31.0

## List of PRs

-
#3983
-
#3987
-
#3989
-
#3991
-
#4010
-
#4015
-
#4020
-
#4029
- [Already existing]
#4039
-
#4047

## Needs double-check

-
#3964
- [Original
commit](560d1b5#diff-3a70a725140527b922181806417d7510bb1c7a19ee9243a0dce4ce7d826ab235)
- [Cherry-picked
commit](058addc)
- Follow up:
[85c364a](85c364a)
-
#4003
- [Original
commit](7406046)
- [Cherry-picked
commit](92b3bca)
-
#4012
- [Original
commit](58c4641)
- [Cherry-picked
commit](4225660)
  - This is only TS check so I think it shouldn't break anything 
-
#4023
- [Original
commit](3918d8a)
- [Cherry-picked
commit](e7e8506)
- I've checked that only formatting part was skipped, so up to you if
you want to check that as well
  
## Test plan

🚀

---------

Co-authored-by: Janic Duplessis <janicduplessis@gmail.com>
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
Co-authored-by: Andreas Högström <andreas.hogstrom@navigraph.com>
Co-authored-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
Co-authored-by: David Duarte <34779165+DavidDuarte22@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants