Skip to content

Commit c19b3d7

Browse files
Fix lint
1 parent 79d37fc commit c19b3d7

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

packages/base-data-service/src/createUIQueryClient.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Messenger } from '@metamask/messenger';
22
import { Json } from '@metamask/utils';
33
import {
4+
DehydratedState,
45
InfiniteData,
56
InfiniteQueryObserver,
67
QueryClient,
@@ -15,6 +16,7 @@ import {
1516
ExampleDataServiceActions,
1617
ExampleMessenger,
1718
GetActivityResponse,
19+
GetAssetsResponse,
1820
} from '../tests/ExampleDataService';
1921
import {
2022
mockAssets,
@@ -33,9 +35,11 @@ function createClient(serviceMessenger: ExampleMessenger): QueryClient {
3335

3436
const messengerAdapter = {
3537
call: async (
36-
method: ExampleDataServiceActions['type'],
38+
method: string,
3739
...params: Json[]
38-
) => {
40+
): Promise<
41+
void | DehydratedState | GetActivityResponse | GetAssetsResponse
42+
> => {
3943
if (method === 'ExampleDataService:subscribe') {
4044
return serviceMessenger.call(
4145
method,
@@ -49,7 +53,11 @@ function createClient(serviceMessenger: ExampleMessenger): QueryClient {
4953
subscription,
5054
);
5155
}
52-
return serviceMessenger.call(method, ...params);
56+
return serviceMessenger.call(
57+
method as ExampleDataServiceActions['type'],
58+
// @ts-expect-error TODO.
59+
...params,
60+
);
5361
},
5462
subscribe: async (
5563
_method: string,

packages/base-data-service/src/createUIQueryClient.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ function getServiceFromQueryKey(queryKey: QueryKey): string {
1212
return queryKey[0].split(':')[0];
1313
}
1414

15+
// When UI messengers are available this should simply be a proper messenger that allows access to DataServiceActions
1516
type MessengerAdapter = {
16-
call: (method: string, ...params: Json[]) => Promise<Json>;
17+
call: (method: string, ...params: Json[]) => Promise<Json | void>;
1718
subscribe: (method: string, callback: (data: Json) => void) => void;
1819
};
1920

@@ -47,11 +48,11 @@ export function createUIQueryClient(
4748
'Queries must use data service actions.',
4849
);
4950

50-
return await messenger.call(
51+
return (await messenger.call(
5152
action,
5253
...(options.queryKey.slice(1) as Json[]),
5354
options.pageParam,
54-
);
55+
)) as Json;
5556
},
5657
// TODO: Decide on values for these.
5758
staleTime: Infinity,

0 commit comments

Comments
 (0)