Skip to content

types_generated fails its own type check under skipLibCheck: false: AnimatedProps.d.ts (TS2411), VirtualizedList.d.ts (TS2344), ReactNativeDocument.d.ts (TS2416) #59647

Open

Description

@YevheniiKotyrlo

Description

Importing react-native from a project that type-checks its dependencies' declarations (skipLibCheck: false) fails with three errors inside types_generated, the declarations the package's exports point at. Each comes from a translation of the Flow source that TypeScript reads differently:

  • Libraries/Animated/nodes/AnimatedProps.d.ts: AnimatedPropsAllowlist has style?: AnimatedStyleAllowlist | undefined beside the index signature [key: string]: true | AnimatedStyleAllowlist. The optional property's undefined is outside the index signature's type, so TypeScript reports TS2411. The Flow source (AnimatedProps.js L28-L31) writes style?: ?AnimatedStyleAllowlist.
  • Libraries/Lists/VirtualizedList.d.ts: VirtualizedListInstance = React.ComponentRef<VirtualizedListType>, translated from React.ElementRef<VirtualizedListType> (VirtualizedList.js L20). @types/react's ComponentRef requires an ElementType, and the VirtualizedList class is not one, since its getDerivedStateFromProps takes VirtualizedListProps where ComponentClass<any> passes Readonly<any> (TS2344).
  • src/private/webapis/dom/nodes/ReactNativeDocument.d.ts: ReactNativeDocument overrides textContent with type null (ReactNativeDocument.js L78), while ReadOnlyNode declares get textContent(): string (ReadOnlyNode.js L188). Flow accepts the override; TypeScript reports TS2416.

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:declarations. It type-checks declarations/import-react-native.ts, which is import {View} from 'react-native', with strict: true, skipLibCheck: false, lib: ["ES2024"] and types: [].

Expected: no errors.
Seen: the three errors below. 0.88.1 prints the same three.

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

node_modules/react-native/types_generated/Libraries/Animated/nodes/AnimatedProps.d.ts(19,3): error TS2411: Property 'style' of type 'Readonly<{ [$$Key$$: string]: true; }> | undefined' is not assignable to 'string' index type 'true | Readonly<{ [$$Key$$: string]: true; }>'.
node_modules/react-native/types_generated/Libraries/Lists/VirtualizedList.d.ts(17,58): error TS2344: Type 'typeof VirtualizedList' does not satisfy the constraint 'ElementType<any, keyof IntrinsicElements>'.
  Type 'typeof VirtualizedList' is not assignable to type 'ComponentClass<any, any>'.
    Types of property 'getDerivedStateFromProps' are incompatible.
      Type '(newProps: VirtualizedListProps, prevState: State) => State' is not assignable to type 'GetDerivedStateFromProps<any, any>'.
        Types of parameters 'newProps' and 'nextProps' are incompatible.
          Type 'Readonly<any>' is not assignable to type 'VirtualizedListProps'.
            Type 'Readonly<any>' is missing the following properties from type 'Omit<RequiredVirtualizedListProps, keyof OptionalVirtualizedListProps>': getItem, getItemCount
node_modules/react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeDocument.d.ts(29,7): error TS2416: Property 'textContent' in type 'ReactNativeDocument' is not assignable to the same property in base type 'ReadOnlyNode'.
  Type 'null' is not assignable to type 'string'.

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. 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: it widens the index signature with | undefined, writes InstanceType<VirtualizedListType>, and widens ReadOnlyNode's getter to string | null, which clears all three errors under skipLibCheck: false.

    diff --git a/types_generated/Libraries/Animated/nodes/AnimatedProps.d.ts b/types_generated/Libraries/Animated/nodes/AnimatedProps.d.ts
    --- a/types_generated/Libraries/Animated/nodes/AnimatedProps.d.ts
    +++ b/types_generated/Libraries/Animated/nodes/AnimatedProps.d.ts
    @@ -17,7 +17,7 @@ import type { AnimatedStyleAllowlist } from "./AnimatedStyle";
     import AnimatedNode from "./AnimatedNode";
     export type AnimatedPropsAllowlist = Readonly<{
       style?: AnimatedStyleAllowlist | undefined;
    -  [key: string]: true | AnimatedStyleAllowlist;
    +  [key: string]: true | AnimatedStyleAllowlist | undefined;
     }>;
     type TargetViewInstance = React.ComponentRef<React.ElementType>;
     declare class AnimatedProps extends AnimatedNode {
    diff --git a/types_generated/Libraries/Lists/VirtualizedList.d.ts b/types_generated/Libraries/Lists/VirtualizedList.d.ts
    --- a/types_generated/Libraries/Lists/VirtualizedList.d.ts
    +++ b/types_generated/Libraries/Lists/VirtualizedList.d.ts
    @@ -14,7 +14,7 @@ import VirtualizedLists from "@react-native/virtualized-lists";
     import * as React from "react";
     type VirtualizedListType = typeof VirtualizedLists.VirtualizedList;
     declare const VirtualizedListComponent: VirtualizedListType;
    -export type VirtualizedListInstance = React.ComponentRef<VirtualizedListType>;
    +export type VirtualizedListInstance = InstanceType<VirtualizedListType>;
     export type { ListRenderItemInfo, ListRenderItem, ListViewToken, Separators, VirtualizedListProps } from "@react-native/virtualized-lists";
     declare const $$VirtualizedList: typeof VirtualizedListComponent;
     declare type $$VirtualizedList = typeof $$VirtualizedList;
    diff --git a/types_generated/src/private/webapis/dom/nodes/ReadOnlyNode.d.ts b/types_generated/src/private/webapis/dom/nodes/ReadOnlyNode.d.ts
    --- a/types_generated/src/private/webapis/dom/nodes/ReadOnlyNode.d.ts
    +++ b/types_generated/src/private/webapis/dom/nodes/ReadOnlyNode.d.ts
    @@ -42,7 +42,7 @@ declare class ReadOnlyNode extends ReadOnlyNodeBase {
       /**
        * @abstract
        */
    -  get textContent(): string;
    +  get textContent(): string | null;
       compareDocumentPosition(otherNode: ReadOnlyNode): number;
       contains(otherNode: ReadOnlyNode): boolean;
       getRootNode(): ReadOnlyNode;
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