Skip to content

The published types reference src/types/globals.d.ts, whose globals conflict with TypeScript's DOM library under skipLibCheck: false #59649

Open

Description

@YevheniiKotyrlo

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

  1. Clone https://github.com/YevheniiKotyrlo/react-native-typescript-declarations and run yarn install in ReproducerApp. It runs react-native@0.89.0-nightly-20261029-25b05acd7 with TypeScript 7.0.2 and @types/react 19.3.0.
  2. Run yarn check:dom. It type-checks declarations/import-react-native.ts, which is import {View} from 'react-native', with strict: true, skipLibCheck: false and lib: ["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.

Activity

  1. Rishabhmk25 commented on Oct 30, 2026

    @Rishabhmk25

    Hey, I'd like to pick this up.

    I reproduced the 69 errors. The cause is the /// to globals.d.ts at the top of index.d.ts (it gets copied from index.js.flow). Taking that line out fixes the DOM case, but apps without the DOM lib would lose fetch, URL, timers, etc.

    I tried keeping the globals behind a react-native-globals export condition that @react-native/typescript-config turns on. With that, the DOM project goes from 72 errors to 3 (the 3 are #59647), and apps on the updated config are unchanged. The downside is that apps with their own tsconfig, or ones that upgrade react-native without the config, would lose the globals, so it's a breaking change.

    Does that trade-off work for you, or would you rather I rework globals.d.ts so it merges with lib.dom instead? I can open a PR either way.

  2. YevheniiKotyrlo commented on Oct 30, 2026

    @YevheniiKotyrlo
    ContributorAuthor

    This is the patch I apply to the published 0.88.0 package until a fix lands: index.d.ts references a globals file that declares only what no TypeScript library declares, so the DOM library, @types/node and bun-types keep their own fetch, URL, Blob and timers.

    diff --git a/types_generated/index.d.ts b/types_generated/index.d.ts
    --- a/types_generated/index.d.ts
    +++ b/types_generated/index.d.ts
    @@ -10,7 +10,7 @@
      * Original file: packages/react-native/index.js.flow
      */
     
    -/// <reference path="../src/types/globals.d.ts" />
    +/// <reference path="react-native-globals.d.ts" />
     
     
     export type { ActivityIndicatorInstance, ActivityIndicatorProps } from "./Libraries/Components/ActivityIndicator/ActivityIndicator";
    diff --git a/types_generated/react-native-globals.d.ts b/types_generated/react-native-globals.d.ts
    new file mode 100644
    --- /dev/null
    +++ b/types_generated/react-native-globals.d.ts
    @@ -0,0 +1,20 @@
    +/**
    + * The globals React Native's runtime adds to the JavaScript environment and no
    + * TypeScript library declares. src/types/globals.d.ts also redeclares fetch,
    + * XMLHttpRequest, URL, WebSocket, Blob, FileReader, AbortController and the
    + * timers, which conflict with lib.dom.d.ts, @types/node and bun-types.
    + */
    +
    +import type { ErrorUtils } from "./Libraries/vendor/core/ErrorUtils";
    +
    +declare global {
    +  const originalXMLHttpRequest: unknown;
    +  const __BUNDLE_START_TIME__: number;
    +  const ErrorUtils: ErrorUtils;
    +  const __DEV__: boolean;
    +  const HermesInternal: null | {};
    +  function clearImmediate(handle: number | null | undefined): void;
    +  function setImmediate(handler: () => void): number;
    +  function setImmediate<Args extends unknown[]>(handler: (...args: Args) => void, ...args: Args): number;
    +  function fetchBundle(bundleId: number, callback: (error?: Error | null) => void): void;
    +}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy