Cannot find type definition file for 'jest'
Nessuno ha ancora preso questa issue.
- Lingua principale
- C++
- Stelle
- 127k
- Fork
- 25.3k
- Merge medio
- 1g 23h
- PR unite (30g)
- 4
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Confronta packages/typescript-config/tsconfig.json con i file del template collegati tsconfig.json e package.json per capire dove sono previsti i tipi Jest. Esegui npx tsc --noEmit nel riproduttore minimo, quindi verifica che la configurazione funzioni per un package senza dipendenze Jest e continui a supportare la configurazione del template.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- react-native, typescript
- Ambito
- mobile-dev, tooling
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100