Skip to content

Commit

Permalink
feat(emitter): add ts-expect-error to avoid overloading error
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Aug 31, 2024
1 parent 4f34f34 commit 8a729b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ export class Emitter<EventsList extends Record<string | symbol | number, any>>
event: Event,
listener: Listener<any, Constructor>
): UnsubscribeFunction {
if (condition === false || (typeof condition === 'function' && !condition())) {
if (!condition || (typeof condition === 'function' && !condition())) {
return () => {}
}

// @ts-expect-error - TypeScript does not like overloading
return this.on(event, listener)
}

Expand Down

0 comments on commit 8a729b4

Please sign in to comment.