WIP - not sure how to get the Flow type working properly

This commit is contained in:
Dominic Gannaway 2017-03-02 21:50:02 +00:00
parent e8f3f92a88
commit da9d91829e
4 changed files with 20 additions and 102 deletions

View File

@ -1,20 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
/* eslint-disable */
declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
inject: ?((stuff: Object) => void)
};*/
// temporary patches for React.Component and React.Element
declare var ReactComponent: typeof React$Component;
declare var ReactElement: typeof React$Element;

View File

@ -1,64 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
/* eslint-disable */
declare module 'deepDiffer' {
declare function exports(one: any, two: any): bool;
}
declare module 'deepFreezeAndThrowOnMutationInDev' {
declare function exports<T>(obj : T) : T;
}
declare module 'flattenStyle' { }
declare module 'InitializeCore' { }
declare module 'RCTEventEmitter' {
declare function register() : void;
}
declare module 'TextInputState' {
declare function blurTextInput(object : any) : void;
declare function focusTextInput(object : any) : void;
}
declare module 'UIManager' {
declare var customBubblingEventTypes : Object;
declare var customDirectEventTypes : Object;
declare function createView(
reactTag : number,
viewName : string,
rootTag : number,
props : ?Object,
) : void;
declare function manageChildren(
containerTag : number,
moveFromIndices : Array<number>,
moveToIndices : Array<number>,
addChildReactTags : Array<number>,
addAtIndices : Array<number>,
removeAtIndices : Array<number>
) : void;
declare function measure() : void;
declare function measureInWindow() : void;
declare function measureLayout() : void;
declare function removeRootView() : void;
declare function removeSubviewsFromContainerWithID() : void;
declare function replaceExistingNonRootView() : void;
declare function setChildren(
containerTag : number,
reactTags : Array<number>,
) : void;
declare function updateView(
reactTag : number,
viewName : string,
props : ?Object,
) : void;
}
declare module 'View' {
declare var exports : typeof ReactComponent;
}

View File

@ -14,16 +14,18 @@
import type { Fiber } from 'ReactFiber';
import type { DebugID } from 'ReactInstanceType';
import type { ComponentTreeHookType } from '../../hooks/ReactComponentTreeHook';
import type { ComponentTreeHookDevType } from '../../hooks/ReactComponentTreeHook';
const ReactDebugCurrentFrame = {};
if (__DEV__) {
// how do a state that ReactComponentTreeHook is using the ComponentTreeHookDevType type?
const ReactComponentTreeHook: ComponentTreeHookDevType = require('ReactComponentTreeHook');
const {
getStackAddendumByID,
getStackAddendumByWorkInProgressFiber,
getCurrentStackAddendum,
}: ComponentTreeHookType = require('ReactComponentTreeHook');
} = ReactComponentTreeHook;
// Component that is being worked on
ReactDebugCurrentFrame.current = (null : Fiber | DebugID | null);
@ -38,9 +40,7 @@ if (__DEV__) {
if (typeof current === 'number') {
// DebugID from Stack.
const debugID = current;
if (getStackAddendumByID) {
stack = getStackAddendumByID(debugID);
}
stack = getStackAddendumByID(debugID);
} else if (typeof current.tag === 'number') {
// This is a Fiber.
// The stack will only be correct if this is a work in progress
@ -49,9 +49,7 @@ if (__DEV__) {
stack = getStackAddendumByWorkInProgressFiber(workInProgress);
}
} else if (element !== null) {
if (getCurrentStackAddendum) {
stack = getCurrentStackAddendum(element);
}
stack = getCurrentStackAddendum(element);
}
return stack;
};

View File

@ -57,16 +57,20 @@ function describeFiber(fiber : Fiber) : string {
export type ComponentTreeHookType = {
getStackAddendumByWorkInProgressFiber: (Fiber) => any,
getStackAddendumByID?: () => any,
getCurrentStackAddendum?: () => any,
purgeUnmountedComponents?: () => any,
getOwnerID?: (DebugID) => any,
getParentID?: (DebugID) => any,
getDisplayName?: (DebugID) => any,
getText?: (DebugID) => any,
getUpdateCount?: (DebugID) => any,
getChildIDs?: (DebugID) => any,
getRegisteredIDs?: () => any,
};
export type ComponentTreeHookDevType = {
getStackAddendumByWorkInProgressFiber: (Fiber) => any,
getStackAddendumByID: () => any,
getCurrentStackAddendum: () => any,
purgeUnmountedComponents: () => any,
getOwnerID: (DebugID) => any,
getParentID: (DebugID) => any,
getDisplayName: (DebugID) => any,
getText: (DebugID) => any,
getUpdateCount: (DebugID) => any,
getChildIDs: (DebugID) => any,
getRegisteredIDs: () => any,
};
var ReactComponentTreeHook: ComponentTreeHookType = {