Skip to content

Commit

Permalink
Accept from that return undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pablof7z committed Aug 1, 2024
1 parent 81784d5 commit b47e829
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ndk-svelte/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { type Unsubscriber, type Writable, writable } from "svelte/store";
* Type for NDKEvent classes that have a static `from` method like NDKHighlight.
*/
type ClassWithConvertFunction<T extends NDKEvent> = {
from: (event: NDKEvent) => T;
from: (event: NDKEvent) => T | undefined;
};

export type ExtendedBaseType<T extends NDKEvent> = T & {
Expand Down Expand Up @@ -195,7 +195,9 @@ class NDKSvelte extends NDK {

let e = event;
if (klass) {
e = klass.from(event);
const ev = klass.from(event);
if (!ev) return;
e = ev;
e.relay = event.relay;
}
e.ndk = this;
Expand Down

0 comments on commit b47e829

Please sign in to comment.