From e1ceaabbffa19c608e2ec5238f8376ac8a2f4980 Mon Sep 17 00:00:00 2001 From: megaproxy Date: Tue, 26 May 2026 19:06:19 +0100 Subject: [PATCH] Fix tsc -b error: bind narrowed SSH spawn spec to a local before closure use buildConfirmInfo's spawn_pane case used `a.spec!.hostId` inside a hosts.find() callback, which compiles under tsc --noEmit (what pnpm check runs) but fails under tsc -b (what pnpm build runs): the non-null assertion drops the kind==="ssh" narrowing the parent ternary had established, so .hostId can't be resolved against the WSL/PowerShell variants of the union. Fix: bind a.spec to a local const inside the narrowed if-block so the closure carries the SSH variant through. Caught by pnpm tauri build during v0.3.0 release prep. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/App.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4f6374d..276bd4b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1265,14 +1265,18 @@ export default function App() { case "spawn_pane": { const a = args as { spec?: SpawnSpec }; const summary = a.spec ? `Spawn ${describeSpec(a.spec)} pane` : "Spawn pane"; - const ssh = - a.spec && a.spec.kind === "ssh" - ? { - hostLabel: a.spec.hostId - ? hosts.find((h) => h.id === a.spec!.hostId)?.label ?? a.spec.host - : a.spec.host, - } - : undefined; + // Bind the narrowed SSH variant to a local so the closure inside + // hosts.find() doesn't lose the discriminant. Using a.spec! here + // would compile under tsc --noEmit but fail under tsc -b. + let ssh: { hostLabel: string } | undefined; + if (a.spec && a.spec.kind === "ssh") { + const sshSpec = a.spec; + ssh = { + hostLabel: sshSpec.hostId + ? hosts.find((h) => h.id === sshSpec.hostId)?.label ?? sshSpec.host + : sshSpec.host, + }; + } return { summary, ssh }; } case "connect_host": {