A small notification badge loader became unstable after a recent refactor. The code still compiles, but in some scenarios it accepts unsuitable data and lets external code modify a reused result.
loadNoticeBadge function accepts a string scope and an asynchronous fetchBadge source.scope or one containing only whitespace must be rejected with the error Scope is required.scope must be normalized: trimmed at both ends and converted to lowercase.scope field is a string and matches the normalized request;count field is a finite number;labels field is an array of strings.scope must use the cache.src/badge.ts.labels contains a non-string value, for example:await loadNoticeBadge(" Inbox ", async () => ({
scope: "inbox",
count: 3,
labels: ["new", 7]
}));
const first = await loadNoticeBadge("Inbox", fetchBadge);
first.labels.push("manual");
const second = await loadNoticeBadge(" inbox ", fetchBadge);
Invalid badge payload.scope.22.x5.8ES modulestsconfig: strict: truetsc --noEmitUse line comments to explain the problem, its impact, the fix and how to test it.