From 8c684bf7e19d6942eb9adb9d16aefe5dc8491bfa Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 27 Aug 2019 10:42:02 -0700 Subject: [PATCH] Removed forked DevTools Flow types --- .../src/backend/console.js | 3 +- .../src/backend/renderer.js | 2 +- .../src/backend/types.js | 106 +----------------- .../src/devtools/views/Components/types.js | 6 +- 4 files changed, 7 insertions(+), 110 deletions(-) diff --git a/packages/react-devtools-shared/src/backend/console.js b/packages/react-devtools-shared/src/backend/console.js index 765f0381000b8..4d18afbd25685 100644 --- a/packages/react-devtools-shared/src/backend/console.js +++ b/packages/react-devtools-shared/src/backend/console.js @@ -3,7 +3,8 @@ import {getInternalReactConstants} from './renderer'; import describeComponentFrame from './describeComponentFrame'; -import type {Fiber, ReactRenderer} from './types'; +import type {Fiber} from 'react-reconciler/src/ReactFiber'; +import type {ReactRenderer} from './types'; const APPEND_STACK_TO_METHODS = ['error', 'trace', 'warn']; diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index 9eafedaa9548b..904e99905b5cc 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -42,11 +42,11 @@ import { registerRenderer as registerRendererWithConsole, } from './console'; +import type {Fiber} from 'react-reconciler/src/ReactFiber'; import type { ChangeDescription, CommitDataBackend, DevToolsHook, - Fiber, InspectedElement, InspectedElementPayload, InstanceAndStyle, diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js index 94db834ba9a30..4f0f7e552cfd4 100644 --- a/packages/react-devtools-shared/src/backend/types.js +++ b/packages/react-devtools-shared/src/backend/types.js @@ -1,5 +1,8 @@ // @flow +import type {ReactContext} from 'shared/ReactTypes'; +import type {Source} from 'shared/ReactElementType'; +import type {Fiber} from 'react-reconciler/src/ReactFiber'; import type { ComponentFilter, ElementType, @@ -14,69 +17,6 @@ type BundleType = export type WorkTag = number; export type SideEffectTag = number; export type ExpirationTime = number; -export type RefObject = {| - current: any, -|}; -export type Source = {| - fileName: string, - lineNumber: number, -|}; - -export type HookType = - | 'useState' - | 'useReducer' - | 'useContext' - | 'useRef' - | 'useEffect' - | 'useLayoutEffect' - | 'useCallback' - | 'useMemo' - | 'useImperativeHandle' - | 'useDebugValue'; - -// The Fiber type is copied from React and should be kept in sync: -// https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiber.js -// The properties we don't use in DevTools are omitted. -export type Fiber = {| - tag: WorkTag, - - key: null | string, - - // Dependencies (contexts, events) for this fiber, if it has any - dependencies: mixed | null, - - elementType: any, - - type: any, - - stateNode: any, - - return: Fiber | null, - - child: Fiber | null, - sibling: Fiber | null, - index: number, - - ref: null | (((handle: mixed) => void) & {_stringRef: ?string}) | RefObject, - - pendingProps: any, // This type will be more specific once we overload the tag. - memoizedProps: any, // The props used to create the output. - - memoizedState: any, - - effectTag: SideEffectTag, - - alternate: Fiber | null, - - actualDuration?: number, - - actualStartTime?: number, - - treeBaseDuration?: number, - - _debugSource?: Source | null, - _debugOwner?: Fiber | null, -|}; // TODO: If it's useful for the frontend to know which types of data an Element has // (e.g. props, state, context, hooks) then we could add a bitmask field for this @@ -103,22 +43,6 @@ export type ReactProviderType = { _context: ReactContext, }; -export type ReactContext = { - $$typeof: Symbol | number, - Consumer: ReactContext, - Provider: ReactProviderType, - - _calculateChangedBits: ((a: T, b: T) => number) | null, - - _currentValue: T, - _currentValue2: T, - _threadCount: number, - - // DEV only - _currentRenderer?: Object | null, - _currentRenderer2?: Object | null, -}; - export type ReactRenderer = { findFiberByHostInstance: (hostInstance: NativeType) => ?Fiber, version: string, @@ -349,27 +273,3 @@ export type DevToolsHook = { commitPriority?: number, ) => void, }; - -export type ReactEventResponder = { - $$typeof: Symbol | number, - displayName: string, - targetEventTypes: null | Array, - rootEventTypes: null | Array, - getInitialState: null | ((props: Object) => Object), - onEvent: - | null - | ((event: E, context: C, props: Object, state: Object) => void), - onRootEvent: - | null - | ((event: E, context: C, props: Object, state: Object) => void), - onMount: null | ((context: C, props: Object, state: Object) => void), - onUnmount: null | ((context: C, props: Object, state: Object) => void), - onOwnershipChange: - | null - | ((context: C, props: Object, state: Object) => void), -}; - -export type ReactEventResponderListener = {| - props: Object, - responder: ReactEventResponder, -|}; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/types.js b/packages/react-devtools-shared/src/devtools/views/Components/types.js index 210a6907b565c..1a7c4af0360b2 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/types.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/types.js @@ -1,5 +1,6 @@ // @flow +import type {Source} from 'shared/ReactElementType'; import type { Dehydrated, Unserializable, @@ -48,11 +49,6 @@ export type OwnersList = {| owners: Array | null, |}; -export type Source = {| - fileName: string, - lineNumber: number, -|}; - export type InspectedElement = {| id: number,