Below is a regression diff for a small TypeScript panel that receives offer data from an API and builds a short string for the preview screen. After the change, users report that some incorrect responses now look like a successful load, and reopening an already viewed offer sometimes unexpectedly changes local data.
loadOfferPreview function must return a state object of the PreviewState shape.offerId or one consisting only of whitespace must not be sent to the API.summary string must be composed from the offer title and the list of active tags.loadOfferPreview on incorrect API responses.offerId from cache.payload shape is checked.Example scenarios:
const malformed = {
id: "offer-7",
payload: { title: "Starter", tags: ["ok", 2] }
};
const first = await loadOfferPreview(" offer-7 ", async () => malformed);
if (first.status === "ready") {
first.offer.tags.push("manual");
}
const second = await loadOfferPreview("offer-7", async () => {
throw new Error("should not be called on cache hit");
});
summary must remain consistent with the offer data.22.x5.8.xES modulesstrict=truenpx tsc --noEmitfetchOffer loader returns Promise<unknown>Use line comments to explain the problem, its impact, the fix and how to test it.