The published types reference src/types/globals.d.ts, whose globals conflict with TypeScript's DOM library under skipLibCheck: false
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 70/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react-native, typescript
- Domaine
- developer-experience, mobile-dev
Piste de recherche
Start with the types_generated/index.d.ts reference to src/types/globals.d.ts and the mandatory reproducer linked in the issue. Run yarn check:dom there to confirm the declaration conflicts with the DOM library. The issue is resolved when importing View with the stated TypeScript settings produces no errors from React Native's declarations.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
types_generated/index.d.ts, the declaration file the package's exports name for react-native, starts with /// <reference path="../src/types/globals.d.ts" />. That file (globals.d.ts) declares its own fetch, Headers, Request, Response, FormData, XMLHttpRequest, URL, URLSearchParams, WebSocket, Blob, File, FileReader, AbortController, AbortSignal and timers as globals, and they differ from the declarations TypeScript's lib.dom.d.ts makes of the same names. So a project that type-checks its dependencies' declarations (skipLibCheck: false) and includes the DOM library, as a project sharing code with the web does, gets 69 errors in globals.d.ts from a plain import {View} from 'react-native'.
The generated declarations themselves import the Blob, FormData and ErrorUtils types they use by path, so the reference only adds these globals.
Steps to reproduce
- Clone https://github.com/YevheniiKotyrlo/react-native-typescript-declarations and run
yarn installinReproducerApp. It runs[email protected]with TypeScript 7.0.2 and@types/react19.3.0. - Run
yarn check:dom. It type-checksdeclarations/import-react-native.ts, which isimport {View} from 'react-native', withstrict: true,skipLibCheck: falseandlib: ["ES2024", "DOM", "DOM.Iterable"].
Expected: no errors from react-native's declarations.
Seen: 72 errors, 69 of them from the globals in src/types/globals.d.ts (TS2300, TS2403, TS2687, TS2717) and three from types_generated itself, which I reported in #59647. 0.88.1 prints the same 72.
React Native Version
0.88.1, and 0.89.0-nightly-20261029-25b05acd7
Affected Platforms
Other (please specify)
Output of npx @react-native-community/cli info
System:
OS: Windows 11 10.0.26300
Binaries:
Node:
version: 26.12.1
Yarn:
version: 1.22.22
npmPackages:
"@react-native-community/cli":
installed: 20.2.0
wanted: 20.2.0
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.89.0-nightly-20261029-25b05acd7
wanted: 0.89.0-nightly-20261029-25b05acd7
The defect is in the published TypeScript declarations, so it shows on every platform; the reproducer only runs tsc.
Stacktrace or Logs
The first errors of yarn check:dom, cut at 200 characters:
node_modules/react-native/src/types/globals.d.ts(218,8): error TS2300: Duplicate identifier 'EndingType'.
node_modules/react-native/src/types/globals.d.ts(219,8): error TS2300: Duplicate identifier 'BlobPart'.
node_modules/react-native/src/types/globals.d.ts(220,8): error TS2300: Duplicate identifier 'BufferSource'.
node_modules/react-native/src/types/globals.d.ts(238,7): error TS2403: Subsequent variable declarations must have the same type. Variable 'Blob' must be of type '{ new (blobParts?: BlobPart[] | undef
node_modules/react-native/src/types/globals.d.ts(252,7): error TS2403: Subsequent variable declarations must have the same type. Variable 'File' must be of type '{ new (fileBits: BlobPart[], fileName
node_modules/react-native/src/types/globals.d.ts(273,9): error TS2300: Duplicate identifier 'FormData'.
node_modules/react-native/src/types/globals.d.ts(338,5): error TS2717: Subsequent property declarations must have the same type. Property 'body' must be of type 'BodyInit | null | undefined', but her
node_modules/react-native/src/types/globals.d.ts(347,5): error TS2717: Subsequent property declarations must have the same type. Property 'signal' must be of type 'AbortSignal | null | undefined', bu
node_modules/react-native/src/types/globals.d.ts(357,14): error TS2717: Subsequent property declarations must have the same type. Property 'signal' must be of type 'AbortSignal', but here has type 'A
node_modules/react-native/src/types/globals.d.ts(361,7): error TS2403: Subsequent variable declarations must have the same type. Variable 'Request' must be of type '{ new (input: URL | RequestInfo, i
node_modules/react-native/src/types/globals.d.ts(366,8): error TS2300: Duplicate identifier 'RequestInfo'.
node_modules/react-native/src/types/globals.d.ts(385,7): error TS2403: Subsequent variable declarations must have the same type. Variable 'Response' must be of type '{ new (body?: BodyInit | null | u
node_modules/react-native/src/types/globals.d.ts(465,5): error TS2717: Subsequent property declarations must have the same type. Property 'abort' must be of type 'ProgressEvent<XMLHttpRequestEventTar
node_modules/react-native/src/types/globals.d.ts(466,5): error TS2717: Subsequent property declarations must have the same type. Property 'error' must be of type 'ProgressEvent<XMLHttpRequestEventTar
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/react-native-typescript-declarations
Screenshots and Videos
None: the failure is the type checker's output above.
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.4k
- Merge moyen
- 2 j 9 h
- PR mergées (30 j)
- 91
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de react/react-native
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
react/react-native#59722 ·
Les mainteneurs répondent en général sous 2 jours
-
Android: new WebSocket() crashes the app for a URL that OkHttp or java.net.URI rejectsPeut-être pris @sorinc03 l’a pris il y a 1 jour. Ouverte🌐Networking Needs: Author Feedback Needs: Repro Platform: Android
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
react/react-native#59704 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
react/react-native#59694 ·
Les mainteneurs répondent en général sous 2 jours
-
Android autolinking keeps a stale autolinking.json when only bun.lock changes, since bun.lock isn't in the default lockFilesPeut-être pris @lazerg l’a pris il y a 3 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
react/react-native#59693 ·
Les mainteneurs répondent en général sous 2 jours
-
Image.resolveAssetSource's TypeScript declaration drops the null it returns for an unknown assetPeut-être pris @Hassan1305 l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
react/react-native#59648 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de react/react-native
Issues similaires
-
bug core p3
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
JdeRobot/RoboticsInfrastructure#843 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
ai-quokka-wannabe/tron-grid-lite#180 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
cython/cython#8110 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
PR bot doesn't recognize hip-tests as a unit test directoryPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ROCm/rocm-systems#14923 ·
Les mainteneurs répondent en général sous 2 jours