fix(typecheck): narrow ctx explicitly and type buildSendElems mock params

CI tsc flagged two strict-mode issues in d1aade6:

  * element-builder: `ctx?.forwardFake` doesn't carry the non-null
    narrowing to a subsequent `ctx.groupId` access — replace with an
    explicit `ctx && ctx.forwardFake` guard.
  * forward-file.test: `vi.fn(async () => [])` infers `mock.calls`
    as `[][]`, so `const [, ctx] = mock.calls[0]!` is "Tuple of length
    '0' has no element at index '1'". Declare the mock's parameter
    types (`unknown[], Record<string, unknown>?`) so the call tuple
    has the right arity, and use `ctx?.groupId` since the ctx slot
    is now typed as optional.
This commit is contained in:
DrSmoothl committed 2026-05-20 14:07:36 +08:00
1 parent d1aade6f87
commit 5d83aedd83
2 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -426,7 +426,7 @@ export async function buildSendElems(elements: MessageElement[], ctx?: SendConte
// the file segment off and writes msgContent
// separately (because RichText.notOnlineFile +
// FileExtra both live outside elems[]).
if (ctx?.forwardFake) {
if (ctx && ctx.forwardFake) {
if (ctx.groupId !== undefined) {
result.push(makeGroupFileElem(elem));
}