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:
parent
420438b494
commit
e1ceaabbff
1 changed files with 12 additions and 8 deletions
20
src/App.tsx
20
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": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue