Skip to content

Commit

Permalink
Remove global React$ type references
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#49276

This diff replaces the remaining `React$` global types in the codebase, in preparation for their removal in Flow.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D69322418

fbshipit-source-id: 058a2489ce8e6bf59df2ec4e61e9708f63561671
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Feb 8, 2025
1 parent b047251 commit e2e5f60
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions flow-typed/npm/react-test-renderer_v16.x.x.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
// Type definitions for react-test-renderer 16.x.x
// Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer

type ReactComponentInstance = React$Component<any>;
type TestRendererOptions = { createNodeMock(element: React.MixedElement): any, ... };

type ReactTestRendererJSON = {
type: string,
props: { [propName: string]: any, ... },
children: null | ReactTestRendererJSON[],
...
};
declare module "react-test-renderer" {
import type {Component as ReactComponent} from 'react';

type ReactTestRendererTree = ReactTestRendererJSON & {
nodeType: "component" | "host",
instance: ?ReactComponentInstance,
rendered: null | ReactTestRendererTree,
...
};
type ReactComponentInstance = ReactComponent<any>;

type ReactTestInstance = {
instance: ?ReactComponentInstance,
type: string,
props: { [propName: string]: any, ... },
parent: null | ReactTestInstance,
children: Array<ReactTestInstance | string>,
find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance,
findByType(type: React$ElementType): ReactTestInstance,
findByProps(props: { [propName: string]: any, ... }): ReactTestInstance,
findAll(
predicate: (node: ReactTestInstance) => boolean,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByType(
type: React$ElementType,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByProps(
export type ReactTestRendererJSON = {
type: string,
props: { [propName: string]: any, ... },
options?: { deep: boolean, ... }
): ReactTestInstance[],
...
};
children: null | ReactTestRendererJSON[],
...
};

type TestRendererOptions = { createNodeMock(element: React.MixedElement): any, ... };
export type ReactTestRendererTree = ReactTestRendererJSON & {
nodeType: "component" | "host",
instance: ?ReactComponentInstance,
rendered: null | ReactTestRendererTree,
...
};

declare module "react-test-renderer" {
declare export type ReactTestRenderer = {
export type ReactTestInstance = {
instance: ?ReactComponentInstance,
type: string,
props: { [propName: string]: any, ... },
parent: null | ReactTestInstance,
children: Array<ReactTestInstance | string>,
find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance,
findByType(type: React.ElementType): ReactTestInstance,
findByProps(props: { [propName: string]: any, ... }): ReactTestInstance,
findAll(
predicate: (node: ReactTestInstance) => boolean,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByType(
type: React.ElementType,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByProps(
props: { [propName: string]: any, ... },
options?: { deep: boolean, ... }
): ReactTestInstance[],
...
};

export type ReactTestRenderer = {
toJSON(): null | ReactTestRendererJSON,
toTree(): null | ReactTestRendererTree,
unmount(nextElement?: React.MixedElement): void,
Expand All @@ -65,6 +67,8 @@ declare module "react-test-renderer" {
}

declare module "react-test-renderer/shallow" {
import type {ReactTestInstance} from 'react-test-renderer';

declare export default class ShallowRenderer {
static createRenderer(): ShallowRenderer;
getMountedInstance(): ReactTestInstance;
Expand Down

0 comments on commit e2e5f60

Please sign in to comment.