Skip to content

Commit fb3b32b

Browse files
committed
internal: Simplify type casting for non-exposed types
1 parent 00d4205 commit fb3b32b

File tree

7 files changed

+12
-20
lines changed

7 files changed

+12
-20
lines changed

packages/core/src/controller/Controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export default class Controller<
267267
args[0] !== null ?
268268
this.dispatch(
269269
createSubscription(endpoint, {
270-
args: args as readonly [...Parameters<E>],
270+
args: args as Parameters<E>,
271271
}),
272272
)
273273
: Promise.resolve();
@@ -289,7 +289,7 @@ export default class Controller<
289289
args[0] !== null ?
290290
this.dispatch(
291291
createUnsubscription(endpoint, {
292-
args: args as readonly [...Parameters<E>],
292+
args: args as Parameters<E>,
293293
}),
294294
)
295295
: Promise.resolve();

packages/react/src/hooks/useDLE.native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default function useDLE<
115115
// revalidating non-suspending data is low priority, so make sure it doesn't stutter animations
116116
const task = InteractionManager.runAfterInteractions(() => {
117117
if (Date.now() > expiresAt && key) {
118-
controller.fetch(endpoint, ...(args as readonly [...Parameters<E>]));
118+
controller.fetch(endpoint, ...(args as Parameters<E>));
119119
}
120120
});
121121

packages/react/src/hooks/useFetch.native.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ export default function useFetch<
6060

6161
// Compute denormalized value
6262
const { expiryStatus, expiresAt } = useMemo(() => {
63-
return controller.getResponse(endpoint, ...args, state) as {
64-
data: Denormalize<E['schema']>;
65-
expiryStatus: ExpiryStatus;
66-
expiresAt: number;
67-
};
63+
return controller.getResponse(endpoint, ...args, state);
6864
// eslint-disable-next-line react-hooks/exhaustive-deps
6965
}, [
7066
cacheResults,
@@ -82,7 +78,7 @@ export default function useFetch<
8278
// null params mean don't do anything
8379
if ((Date.now() <= expiresAt && !forceFetch) || !key) return;
8480
// if args is [null], we won't get to this line
85-
return controller.fetch(endpoint, ...(args as [...Parameters<E>]));
81+
return controller.fetch(endpoint, ...(args as Parameters<E>));
8682
// we need to check against serialized params, since params can change frequently
8783
// eslint-disable-next-line react-hooks/exhaustive-deps
8884
}, [expiresAt, controller, key, forceFetch, state.lastReset]);
@@ -91,7 +87,7 @@ export default function useFetch<
9187
// revalidating non-suspending data is low priority, so make sure it doesn't stutter animations
9288
const task = InteractionManager.runAfterInteractions(() => {
9389
if (Date.now() > expiresAt && key) {
94-
controller.fetch(endpoint, ...(args as readonly [...Parameters<E>]));
90+
controller.fetch(endpoint, ...(args as Parameters<E>));
9591
}
9692
});
9793

packages/react/src/hooks/useFetch.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ export default function useFetch<
5858

5959
// Compute denormalized value
6060
const { expiryStatus, expiresAt } = useMemo(() => {
61-
return controller.getResponse(endpoint, ...args, state) as {
62-
data: Denormalize<E['schema']>;
63-
expiryStatus: ExpiryStatus;
64-
expiresAt: number;
65-
};
61+
return controller.getResponse(endpoint, ...args, state);
6662
// eslint-disable-next-line react-hooks/exhaustive-deps
6763
}, [
6864
cacheResults,
@@ -81,7 +77,7 @@ export default function useFetch<
8177
if ((Date.now() <= expiresAt && !forceFetch) || !key) return;
8278

8379
// if args is [null], we won't get to this line
84-
return controller.fetch(endpoint, ...(args as [...Parameters<E>]));
80+
return controller.fetch(endpoint, ...(args as Parameters<E>));
8581
// we need to check against serialized params, since params can change frequently
8682
// eslint-disable-next-line react-hooks/exhaustive-deps
8783
}, [expiresAt, controller, key, forceFetch, state.lastReset]);

packages/react/src/hooks/useSubscription.native.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function useSubscription<
2727
() => {
2828
if (!key) return;
2929
// typescript cannot infer truthy key means args is not null
30-
const cleanedArgs = args as readonly [...Parameters<E>];
30+
const cleanedArgs = args as Parameters<E>;
3131

3232
controller.subscribe(endpoint, ...cleanedArgs);
3333
return () => {

packages/react/src/hooks/useSuspense.native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default function useSuspense<
8888
return (
8989
controller
9090
// if args is [null], we won't get to this line
91-
.fetch(endpoint, ...(args as [...Parameters<E>]))
91+
.fetch(endpoint, ...(args as Parameters<E>))
9292
.catch(() => {})
9393
);
9494
// we need to check against serialized params, since params can change frequently
@@ -106,7 +106,7 @@ export default function useSuspense<
106106
// revalidating non-suspending data is low priority, so make sure it doesn't stutter animations
107107
const task = InteractionManager.runAfterInteractions(() => {
108108
if (Date.now() > expiresAt && key) {
109-
controller.fetch(endpoint, ...(args as readonly [...Parameters<E>]));
109+
controller.fetch(endpoint, ...(args as Parameters<E>));
110110
}
111111
});
112112

packages/react/src/hooks/useSuspense.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function useSuspense<
8686
return (
8787
controller
8888
// if args is [null], we won't get to this line
89-
.fetch(endpoint, ...(args as [...Parameters<E>]))
89+
.fetch(endpoint, ...(args as Parameters<E>))
9090
.catch(() => {})
9191
);
9292
// we need to check against serialized params, since params can change frequently

0 commit comments

Comments
 (0)