From ecec383f2f02dd615a987ea27961698c3c1448e0 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Wed, 15 Oct 2025 01:31:33 -0500 Subject: [PATCH] Fix nip19 npub decoding type narrowing issue Use negative type guard (decoded.type !== 'npub') to properly narrow the union type, allowing TypeScript to infer decoded.data as string when type is 'npub'. This fixes the type overlap error. --- src/components/git/PullRequestDialog.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/git/PullRequestDialog.tsx b/src/components/git/PullRequestDialog.tsx index d6ea4fcb..6d5db402 100644 --- a/src/components/git/PullRequestDialog.tsx +++ b/src/components/git/PullRequestDialog.tsx @@ -218,11 +218,10 @@ export function PullRequestDialog({ if (pubkeyOrNpub.startsWith('npub1')) { try { const decoded = nip19.decode(pubkeyOrNpub); - if (decoded.type === 'npub') { - owner = decoded.data as string; // hex pubkey - } else { - throw new Error('Invalid npub'); + if (decoded.type !== 'npub') { + throw new Error('Expected npub but got ' + decoded.type); } + owner = decoded.data; // hex pubkey } catch (err) { console.error('Failed to decode npub:', err); setError('Invalid npub in Nostr URL');