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) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-26 19:06:19 +01:00
parent 420438b494
commit e1ceaabbff

View file

@ -1265,14 +1265,18 @@ export default function App() {
case "spawn_pane": { case "spawn_pane": {
const a = args as { spec?: SpawnSpec }; const a = args as { spec?: SpawnSpec };
const summary = a.spec ? `Spawn ${describeSpec(a.spec)} pane` : "Spawn pane"; const summary = a.spec ? `Spawn ${describeSpec(a.spec)} pane` : "Spawn pane";
const ssh = // Bind the narrowed SSH variant to a local so the closure inside
a.spec && a.spec.kind === "ssh" // hosts.find() doesn't lose the discriminant. Using a.spec! here
? { // would compile under tsc --noEmit but fail under tsc -b.
hostLabel: a.spec.hostId let ssh: { hostLabel: string } | undefined;
? hosts.find((h) => h.id === a.spec!.hostId)?.label ?? a.spec.host if (a.spec && a.spec.kind === "ssh") {
: a.spec.host, const sshSpec = a.spec;
} ssh = {
: undefined; hostLabel: sshSpec.hostId
? hosts.find((h) => h.id === sshSpec.hostId)?.label ?? sshSpec.host
: sshSpec.host,
};
}
return { summary, ssh }; return { summary, ssh };
} }
case "connect_host": { case "connect_host": {