Skip to content

Commit

Permalink
fix typings EventNames type
Browse files Browse the repository at this point in the history
  • Loading branch information
arnevogt committed Aug 25, 2023
1 parent b7d6e90 commit 9b97bb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-lemons-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@open-pioneer/core": patch
---

fix typings EventNames type
6 changes: 2 additions & 4 deletions src/packages/core/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { Resource } from "./resources";

const state = Symbol("EventEmitterState");

export type EventNames<Events extends Record<string, unknown>> = keyof Events & string;
export type EventNames<Events extends {}> = keyof Events & string;

type ArgType<T> = [T] extends [void] ? [] : [event: T];

type EventType<Events extends Record<string, unknown>, Name extends keyof Events> = ArgType<
Events[Name]
>;
type EventType<Events extends {}, Name extends keyof Events> = ArgType<Events[Name]>;

/**
* A support class that implements emitting and listening for events.
Expand Down

0 comments on commit 9b97bb7

Please sign in to comment.