From a14c9a4d852eeb00adb9ca3614fd5cf236f7594b Mon Sep 17 00:00:00 2001 From: Li Weinan Date: Fri, 27 Sep 2019 14:39:06 +0800 Subject: [PATCH 1/4] update type definition of withApollo --- packages/hoc/src/withApollo.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hoc/src/withApollo.tsx b/packages/hoc/src/withApollo.tsx index ce32741b40..d0c584a8f2 100644 --- a/packages/hoc/src/withApollo.tsx +++ b/packages/hoc/src/withApollo.tsx @@ -11,10 +11,10 @@ function getDisplayName

(WrappedComponent: React.ComponentType

) { export function withApollo( WrappedComponent: React.ComponentType< - WithApolloClient> + WithApolloClient >, operationOptions: OperationOption = {} -): React.ComponentClass> { +): React.ComponentClass { const withDisplayName = `withApollo(${getDisplayName(WrappedComponent)})`; class WithApollo extends React.Component> { From 09fa138a8cf03e365ba85b475fb66aeacb5e6f50 Mon Sep 17 00:00:00 2001 From: Li Weinan Date: Fri, 27 Sep 2019 14:45:22 +0800 Subject: [PATCH 2/4] Update withApollo.tsx --- packages/hoc/src/withApollo.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/hoc/src/withApollo.tsx b/packages/hoc/src/withApollo.tsx index d0c584a8f2..1ba254456c 100644 --- a/packages/hoc/src/withApollo.tsx +++ b/packages/hoc/src/withApollo.tsx @@ -9,12 +9,10 @@ function getDisplayName

(WrappedComponent: React.ComponentType

) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } -export function withApollo( - WrappedComponent: React.ComponentType< - WithApolloClient - >, +export function withApollo, TResult = any>( + WrappedComponent: React.ComponentType, operationOptions: OperationOption = {} -): React.ComponentClass { +): React.ComponentClass> { const withDisplayName = `withApollo(${getDisplayName(WrappedComponent)})`; class WithApollo extends React.Component> { From ef00bf7f9e98e6223a9f43919270a3c04b08828d Mon Sep 17 00:00:00 2001 From: Li Weinan Date: Fri, 27 Sep 2019 15:28:36 +0800 Subject: [PATCH 3/4] fix compilation error --- packages/hoc/src/withApollo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hoc/src/withApollo.tsx b/packages/hoc/src/withApollo.tsx index 1ba254456c..6acd433604 100644 --- a/packages/hoc/src/withApollo.tsx +++ b/packages/hoc/src/withApollo.tsx @@ -51,7 +51,7 @@ export function withApollo, TResult = any>( ? this.setWrappedInstance : undefined }); - return ; + return ; }} ); From 9931c268d35d0e2abf5e366540596d6018054bff Mon Sep 17 00:00:00 2001 From: Li Weinan Date: Fri, 27 Sep 2019 16:10:12 +0800 Subject: [PATCH 4/4] return type of children of Query component should be React.ReactNode --- packages/components/src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/src/types.ts b/packages/components/src/types.ts index 8cf82f1655..52221e118b 100644 --- a/packages/components/src/types.ts +++ b/packages/components/src/types.ts @@ -14,7 +14,7 @@ export interface QueryComponentOptions< TData = any, TVariables = OperationVariables > extends QueryFunctionOptions { - children: (result: QueryResult) => JSX.Element | null; + children: (result: QueryResult) => React.ReactNode query: DocumentNode; } @@ -32,7 +32,7 @@ export interface MutationComponentOptions< export interface SubscriptionComponentOptions< TData = any, TVariables = OperationVariables -> extends BaseSubscriptionOptions { + > extends BaseSubscriptionOptions { subscription: DocumentNode; children?: null | ((result: SubscriptionResult) => JSX.Element | null); }