From 8cba16f041609443111ecf5fb58faea1b3e79569 Mon Sep 17 00:00:00 2001 From: Alessia Bellisario Date: Mon, 5 Feb 2024 16:33:01 -0500 Subject: [PATCH] fix: unbound-method lint error by using arrow function syntax for fns declared on the ObservableQueryFields interface (#11558) --- .api-reports/api-report-react.md | 16 +++++++------- .api-reports/api-report-react_components.md | 16 +++++++------- .api-reports/api-report-react_context.md | 16 +++++++------- .api-reports/api-report-react_hooks.md | 16 +++++++------- .api-reports/api-report-react_ssr.md | 16 +++++++------- .api-reports/api-report.md | 16 +++++++------- .changeset/forty-rice-taste.md | 5 +++++ src/react/types/types.ts | 24 +++++++++++---------- 8 files changed, 66 insertions(+), 59 deletions(-) create mode 100644 .changeset/forty-rice-taste.md diff --git a/.api-reports/api-report-react.md b/.api-reports/api-report-react.md index a0c6572fe2e..c695431d154 100644 --- a/.api-reports/api-report-react.md +++ b/.api-reports/api-report-react.md @@ -1368,19 +1368,19 @@ class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.api-reports/api-report-react_components.md b/.api-reports/api-report-react_components.md index e567f4b2cec..6b3d3fca46c 100644 --- a/.api-reports/api-report-react_components.md +++ b/.api-reports/api-report-react_components.md @@ -1144,19 +1144,19 @@ class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.api-reports/api-report-react_context.md b/.api-reports/api-report-react_context.md index 02bd085dccf..3d8e53adb6c 100644 --- a/.api-reports/api-report-react_context.md +++ b/.api-reports/api-report-react_context.md @@ -1101,19 +1101,19 @@ class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.api-reports/api-report-react_hooks.md b/.api-reports/api-report-react_hooks.md index 20ef6e04d01..e1b188c020b 100644 --- a/.api-reports/api-report-react_hooks.md +++ b/.api-reports/api-report-react_hooks.md @@ -1313,19 +1313,19 @@ class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.api-reports/api-report-react_ssr.md b/.api-reports/api-report-react_ssr.md index 477152f332d..4bda11ff938 100644 --- a/.api-reports/api-report-react_ssr.md +++ b/.api-reports/api-report-react_ssr.md @@ -1086,19 +1086,19 @@ class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.api-reports/api-report.md b/.api-reports/api-report.md index 515845e2a26..8774f31d096 100644 --- a/.api-reports/api-report.md +++ b/.api-reports/api-report.md @@ -1860,19 +1860,19 @@ export class ObservableQuery { - fetchMore(fetchMoreOptions: FetchMoreQueryOptions & { + fetchMore: (fetchMoreOptions: FetchMoreQueryOptions & { updateQuery?: (previousQueryResult: TData, options: { fetchMoreResult: TFetchData; variables: TFetchVars; }) => TData; - }): Promise>; - refetch(variables?: Partial): Promise>; + }) => Promise>; + refetch: (variables?: Partial) => Promise>; // @internal (undocumented) - reobserve(newOptions?: Partial>, newNetworkStatus?: NetworkStatus): Promise>; - startPolling(pollInterval: number): void; - stopPolling(): void; - subscribeToMore(options: SubscribeToMoreOptions): () => void; - updateQuery(mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData): void; + reobserve: (newOptions?: Partial>, newNetworkStatus?: NetworkStatus) => Promise>; + startPolling: (pollInterval: number) => void; + stopPolling: () => void; + subscribeToMore: (options: SubscribeToMoreOptions) => () => void; + updateQuery: (mapFn: (previousQueryResult: TData, options: Pick, "variables">) => TData) => void; variables: TVariables | undefined; } diff --git a/.changeset/forty-rice-taste.md b/.changeset/forty-rice-taste.md new file mode 100644 index 00000000000..a7017ce8f7e --- /dev/null +++ b/.changeset/forty-rice-taste.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +Fix [`unbound-method`](https://github.com/apollographql/apollo-client/issues/11554) linter error on ObservableQuery methods exposed on useQuery's QueryResult object. diff --git a/src/react/types/types.ts b/src/react/types/types.ts index 785c2ed793b..0c842c6863e 100644 --- a/src/react/types/types.ts +++ b/src/react/types/types.ts @@ -81,11 +81,11 @@ export interface ObservableQueryFields< TVariables extends OperationVariables, > { /** {@inheritDoc @apollo/client!QueryResultDocumentation#startPolling:member} */ - startPolling(pollInterval: number): void; + startPolling: (pollInterval: number) => void; /** {@inheritDoc @apollo/client!QueryResultDocumentation#stopPolling:member} */ - stopPolling(): void; + stopPolling: () => void; /** {@inheritDoc @apollo/client!QueryResultDocumentation#subscribeToMore:member} */ - subscribeToMore< + subscribeToMore: < TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables, >( @@ -94,25 +94,27 @@ export interface ObservableQueryFields< TSubscriptionVariables, TSubscriptionData > - ): () => void; + ) => () => void; /** {@inheritDoc @apollo/client!QueryResultDocumentation#updateQuery:member} */ - updateQuery( + updateQuery: ( mapFn: ( previousQueryResult: TData, options: Pick, "variables"> ) => TData - ): void; + ) => void; /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */ - refetch(variables?: Partial): Promise>; + refetch: ( + variables?: Partial + ) => Promise>; /** @internal */ - reobserve( + reobserve: ( newOptions?: Partial>, newNetworkStatus?: NetworkStatus - ): Promise>; + ) => Promise>; /** {@inheritDoc @apollo/client!QueryResultDocumentation#variables:member} */ variables: TVariables | undefined; /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */ - fetchMore< + fetchMore: < TFetchData = TData, TFetchVars extends OperationVariables = TVariables, >( @@ -125,7 +127,7 @@ export interface ObservableQueryFields< } ) => TData; } - ): Promise>; + ) => Promise>; } export interface QueryResult<