Problem
In poc-sync-engine/src/SyncQueue.ts, the payload property of SyncJob is typed as any:
export interface SyncJob {
id: string;
url: string;
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
payload: any;
timestamp: number;
retryCount: number;
}
Using any here removes compile-time safety for queued payloads and makes queue consumers harder to type correctly.
Proposed Solution
Refactor SyncJob and SyncQueue to support a generic type parameter, allowing consumers to strongly type queued mutation payloads:
export interface SyncJob<T = unknown> {
id: string;
url: string;
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
payload: T;
timestamp: number;
retryCount: number;
}
export class SyncQueue<T = unknown> {
private queue: SyncJob<T>[] = [];
}
A default generic such as unknown can preserve safety while still allowing consumers to specify stricter payload types where needed.
Queue mutation and retrieval methods (e.g. enqueue, dequeue, peek) should preserve the parameterized payload type throughout the API surface.
Acceptance Criteria
Problem
In poc-sync-engine/src/SyncQueue.ts, the
payloadproperty ofSyncJobis typed asany:Using
anyhere removes compile-time safety for queued payloads and makes queue consumers harder to type correctly.Proposed Solution
Refactor
SyncJobandSyncQueueto support a generic type parameter, allowing consumers to strongly type queued mutation payloads:A default generic such as
unknowncan preserve safety while still allowing consumers to specify stricter payload types where needed.Queue mutation and retrieval methods (e.g.
enqueue,dequeue,peek) should preserve the parameterized payload type throughout the API surface.Acceptance Criteria
anytype is removed from theSyncJobpayload property.