Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions packages/clients/tanstack-query/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export type TrimDelegateModelOperations<
T extends Record<string, unknown>,
> = IsDelegateModel<Schema, Model> extends true ? Omit<T, HooksOperationsIneligibleForDelegateModels> : T;

export type WithOptimistic<T> =
T extends Array<infer U>
? Array<
U & {
/**
* Indicates if the item is in an optimistic update state
*/
$optimistic?: boolean;
}
>
: T & {
/**
* Indicates if the item is in an optimistic update state
*/
$optimistic?: boolean;
};
type WithOptimisticFlag<T> = T extends object
? T & {
/**
* Indicates if the item is in an optimistic update state
*/
$optimistic?: boolean;
}
: T;

export type WithOptimistic<T> = T extends Array<infer U> ? Array<WithOptimisticFlag<U>> : WithOptimisticFlag<T>;