Type heterogeneous API batch results
Partition a typed heterogeneous batch into keyed successes and errors while preserving request-key inference.Description
Requirements
Export partitionBatchResults from src/App.tsx.
Put ok values only in successes and failed messages only in errors.
Use the last item for a repeated key and remove its prior opposite partition value.
Keep success and error properties constrained to keyof Requests.
Return fresh null-prototype-safe records without mutating item values.
Return an observably equivalent result for equivalent inputs without reading time, randomness, network, storage, or DOM globals.
Do not mutate input objects, arrays, nested records, or values retained in the returned result.
Mixed batch
user succeeds and posts fails
Successes contains user; errors contains posts
Put ok values only in successes and failed messages only in errors.
Repeated key
user fails then succeeds
Only the success remains
Use the last item for a repeated key and remove its prior opposite partition value.
Constraints
Implement a pure synchronous function with no external side effectsTreat every input collection and nested record as read-onlyReturn JSON-compatible data except where the declared TypeScript API explicitly uses bigint
Hints
Hint 1
Start with the partitions-discriminated-items behavior and make its observable result deterministic.
Hint 2
Model last-key-result-wins independently before combining it with the remaining states.
Hint 3
Verify the boundary described by fresh-records without changing caller-owned input.