fix: resolve TypeScript type issues

- Update AccountWithExtension interface to be more flexible
- Add type guard for runtime type checking
- Change fetchBookmarks parameter to accept unknown type with validation
- All linting and type checks now pass
This commit is contained in:
Gigi
2025-10-02 10:23:01 +02:00
parent a625203fe4
commit 92d49468cd
2 changed files with 15 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
---
description: applesauce reference documentation and examples
alwaysApply: true
---

View File

@@ -22,7 +22,13 @@ interface ApplesauceBookmarks {
interface AccountWithExtension {
pubkey: string
[key: string]: unknown // Allow other properties from the full account object
signer?: unknown
[key: string]: unknown // Allow any properties from the full account object
}
// Type guard to check if an object has the required properties
function isAccountWithExtension(account: unknown): account is AccountWithExtension {
return typeof account === 'object' && account !== null && 'pubkey' in account
}
@@ -85,13 +91,19 @@ const processApplesauceBookmarks = (
export const fetchBookmarks = async (
relayPool: RelayPool,
activeAccount: AccountWithExtension, // Full account object with extension capabilities
activeAccount: unknown, // Full account object with extension capabilities
setBookmarks: (bookmarks: Bookmark[]) => void,
setLoading: (loading: boolean) => void,
timeoutId: number
) => {
try {
setLoading(true)
// Type check the account object
if (!isAccountWithExtension(activeAccount)) {
throw new Error('Invalid account object provided')
}
console.log('🚀 Using applesauce bookmark helpers for pubkey:', activeAccount.pubkey)
// Get relay URLs from the pool