Skip to content

Commit 2946115

Browse files
authored
fix(tanstack): extra optimistic typing fix (#376)
1 parent 56acc1c commit 2946115

File tree

1 file changed

+10
-16
lines changed
  • packages/clients/tanstack-query/src/utils

1 file changed

+10
-16
lines changed

packages/clients/tanstack-query/src/utils/types.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ export type TrimDelegateModelOperations<
3131
T extends Record<string, unknown>,
3232
> = IsDelegateModel<Schema, Model> extends true ? Omit<T, HooksOperationsIneligibleForDelegateModels> : T;
3333

34-
export type WithOptimistic<T> =
35-
T extends Array<infer U>
36-
? Array<
37-
U & {
38-
/**
39-
* Indicates if the item is in an optimistic update state
40-
*/
41-
$optimistic?: boolean;
42-
}
43-
>
44-
: T & {
45-
/**
46-
* Indicates if the item is in an optimistic update state
47-
*/
48-
$optimistic?: boolean;
49-
};
34+
type WithOptimisticFlag<T> = T extends object
35+
? T & {
36+
/**
37+
* Indicates if the item is in an optimistic update state
38+
*/
39+
$optimistic?: boolean;
40+
}
41+
: T;
42+
43+
export type WithOptimistic<T> = T extends Array<infer U> ? Array<WithOptimisticFlag<U>> : WithOptimisticFlag<T>;

0 commit comments

Comments
 (0)