From 70fa01a640c761aaf353fb38e13f56c6dde13f31 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Wed, 15 Oct 2025 01:36:03 -0500 Subject: [PATCH] Fix nip19 decode type inference with explicit type assertion Add explicit type assertion to nip19.decode() result to avoid TypeScript version differences in discriminated union handling. This ensures consistent type checking across different TypeScript versions used in CI/CD vs local. --- src/components/git/PullRequestDialog.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/git/PullRequestDialog.tsx b/src/components/git/PullRequestDialog.tsx index babab13e..86ddb2e9 100644 --- a/src/components/git/PullRequestDialog.tsx +++ b/src/components/git/PullRequestDialog.tsx @@ -217,12 +217,12 @@ export function PullRequestDialog({ // Convert npub to hex if needed if (pubkeyOrNpub.startsWith('npub1')) { try { - const decoded = nip19.decode(pubkeyOrNpub); - // Type guard: ensure we have an npub - if (decoded.type === 'npub' && typeof decoded.data === 'string') { - owner = decoded.data; // hex pubkey + const result = nip19.decode(pubkeyOrNpub) as { type: string; data: string }; + // Validate that we got an npub (public key) + if (result.type === 'npub') { + owner = result.data; } else { - throw new Error('Expected npub but got ' + decoded.type); + throw new Error('Invalid npub - expected public key but got: ' + result.type); } } catch (err) { console.error('Failed to decode npub:', err);