Add <any> type args for ReactElement,Class,Component

This commit is contained in:
Paul O’Shannessy
2016-06-03 13:13:20 -07:00
parent 2efc7186fe
commit dd093faadf
9 changed files with 15 additions and 12 deletions
+4 -1
View File
@@ -207,7 +207,10 @@ if (__DEV__) {
* In the future, we should cleanup callbacks by cancelling them instead of
* using this.
*/
var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any {
function mountSafeCallback(
context: ReactComponent<any, any, any>,
callback: ?Function
): any {
return function() {
if (!callback || (context.isMounted && !context.isMounted())) {
return undefined;
+1 -1
View File
@@ -28,7 +28,7 @@ var render = function(
element: ReactElement,
mountInto: number,
callback?: ?(() => void)
): ?ReactComponent {
): ?ReactComponent<any, any, any> {
return ReactNativeMount.renderComponent(element, mountInto, callback);
};
+2 -2
View File
@@ -101,7 +101,7 @@ var ReactNativeMount = {
nextElement: ReactElement,
containerTag: number,
callback?: ?(() => void)
): ?ReactComponent {
): ?ReactComponent<any, any, any> {
var nextWrappedElement = new ReactElement(
TopLevelWrapper,
null,
@@ -237,7 +237,7 @@ var ReactNativeMount = {
* @see {ReactNativeMount.unmountComponentAtNode}
*/
unmountComponentFromNode: function(
instance: ReactComponent,
instance: ReactComponent<any, any, any>,
containerID: number
) {
// Call back into native to remove all of the subviews from this container
@@ -42,7 +42,7 @@ var createReactNativeComponentClass = function(
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
Constructor.prototype.constructor = Constructor;
return ((Constructor: any): ReactClass);
return ((Constructor: any): ReactClass<any>);
};
module.exports = createReactNativeComponentClass;
+1 -1
View File
@@ -40,7 +40,7 @@ var NoopRenderer = ReactFiberReconciler({
var ReactNoop = {
render(element : ReactElement) {
render(element : ReactElement<any>) {
NoopRenderer.mountNewRoot(element);
@@ -35,7 +35,7 @@ function createSubsequentChild(parent : Fiber, previousSibling : Fiber, newChild
switch (newChildren.$$typeof) {
case REACT_ELEMENT_TYPE: {
const element = (newChildren : ReactElement);
const element = (newChildren : ReactElement<any>);
const child = ReactFiber.createFiberFromElement(element);
previousSibling.sibling = child;
child.parent = parent;
@@ -80,7 +80,7 @@ function createFirstChild(parent, newChildren) {
switch (newChildren.$$typeof) {
case REACT_ELEMENT_TYPE: {
const element = (newChildren : ReactElement);
const element = (newChildren : ReactElement<any>);
const child = ReactFiber.createFiberFromElement(element);
child.parent = parent;
return child;
@@ -39,7 +39,7 @@ export type HostConfig<T, P, I> = {
type OpaqueID = {};
export type Reconciler = {
mountNewRoot(element : ReactElement) : OpaqueID;
mountNewRoot(element : ReactElement<any>) : OpaqueID;
};
module.exports = function<T, P, I>(config : HostConfig<T, P, I>) : Reconciler {
@@ -109,7 +109,7 @@ module.exports = function<T, P, I>(config : HostConfig<T, P, I>) : Reconciler {
return {
mountNewRoot(element : ReactElement) : OpaqueID {
mountNewRoot(element : ReactElement<any>) : OpaqueID {
ensureLowPriIsScheduled();
@@ -14,7 +14,7 @@
import type { ReactCoroutine, ReactYield } from 'ReactCoroutine';
export type ReactNode = ReactElement | ReactCoroutine | ReactYield | ReactText | ReactFragment;
export type ReactNode = ReactElement<any> | ReactCoroutine | ReactYield | ReactText | ReactFragment;
export type ReactFragment = ReactEmpty | Iterable<ReactNode>;
+1 -1
View File
@@ -96,7 +96,7 @@ var ReactHostMount = {
render: function(
nextElement: ReactElement
): ?ReactComponent {
): ?ReactElement<any, any, any> {
var nextWrappedElement = new ReactElement(
TopLevelWrapper,
null,