Cannot find type definition file for 'jest'
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
In a very minimal package declaring a dependency on react-native and the @react-native/typescript-config (such as a very simple library), extending the @react-native/typescript-config yields:
error TS2688: Cannot find type definition file for 'jest'.
The file is in the program because:
Entry point of type library 'jest' specified in compilerOptions
This happens because the tsconfig declares "types": ["jest"], while neither "react-native" nor "@react-native/typescript-config" declare a dependency on neither jest nor @types/jest.
I'd suggest moving the "types": ["jest"], to the template's tsconfig: https://github.com/react-native-community/template/blob/d2a0bee199b49611ee252dd5d7626f10a714bebd/template/tsconfig.json#L2 since that's the package bringing the jest dependency.
Steps to reproduce
Init a new package with this package.json
{
"name": "react-native-ts-test",
"private": true,
"version": "0.1.0",
"scripts": {
"build": "tsc --noEmit"
},
"devDependencies": {
"@react-native/typescript-config": "^0.81.1",
"typescript": "^5.9.2"
},
"dependencies": {
"react-native": "^0.81.1"
}
}
and this tsconfig.json
{
"extends": "@react-native/typescript-config",
"include": ["src/index.ts"]
}
Run npx tsc --noEmit 💥
error TS2688: Cannot find type definition file for 'jest'.
The file is in the program because:
Entry point of type library 'jest' specified in compilerOptions
React Native Version
0.81.1
Affected Platforms
Build - MacOS, Build - Windows, Build - Linux
Output of npx @react-native-community/cli info
N/A
Stacktrace or Logs
error TS2688: Cannot find type definition file for 'jest'.
The file is in the program because:
Entry point of type library 'jest' specified in compilerOptions
MANDATORY Reproducer
https://github.com/react-native-community/reproducer-react-native
Screenshots and Videos
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
packages/typescript-config/tsconfig.json と、リンク先のテンプレートの tsconfig.json および package.json ファイルを比較して、Jest の型がどこで想定されているかを確認します。最小限の再現例で npx tsc --noEmit を実行し、その後、Jest の依存関係がないパッケージでも設定が機能し、テンプレートのセットアップも引き続きサポートされることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react-native, typescript
- 領域
- mobile-dev, tooling
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100