Skip to content

Commit ed4be71

Browse files
marthakellyclaude
andcommitted
test(core): narrow invocationCallOrder access for tsc strict mode
vitest types invocationCallOrder as `number[]`, but TS narrows indexed access to `number | undefined` under noUncheckedIndexedAccess. Capture the entries first, assert each is defined, then compare — keeps the ordering check intact while satisfying tsc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7438782 commit ed4be71

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/core/src/__tests__/thread-store-registry.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ describe("ThreadStoreRegistry", () => {
111111
// The unregister notification for the previous store must fire before
112112
// the second register notification — subscribers rely on this ordering
113113
// to tear down stale subscriptions before wiring up the replacement.
114-
expect(onUnregistered.mock.invocationCallOrder[0]).toBeLessThan(
115-
onRegistered.mock.invocationCallOrder[1],
116-
);
114+
const unregisterOrder = onUnregistered.mock.invocationCallOrder[0];
115+
const secondRegisterOrder = onRegistered.mock.invocationCallOrder[1];
116+
expect(unregisterOrder).toBeDefined();
117+
expect(secondRegisterOrder).toBeDefined();
118+
expect(unregisterOrder!).toBeLessThan(secondRegisterOrder!);
117119
});
118120

119121
it("unregister removes the store", () => {
@@ -204,10 +206,14 @@ describe("ThreadStoreRegistry", () => {
204206
onThreadStoreRegistered: ok,
205207
};
206208
(
207-
core as unknown as { subscribe: (s: CopilotKitCoreSubscriber) => unknown }
209+
core as unknown as {
210+
subscribe: (s: CopilotKitCoreSubscriber) => unknown;
211+
}
208212
).subscribe(subscriberA);
209213
(
210-
core as unknown as { subscribe: (s: CopilotKitCoreSubscriber) => unknown }
214+
core as unknown as {
215+
subscribe: (s: CopilotKitCoreSubscriber) => unknown;
216+
}
211217
).subscribe(subscriberB);
212218

213219
const store = makeStore();

0 commit comments

Comments
 (0)