Skip to content

Commit

Permalink
Better typing for signals
Browse files Browse the repository at this point in the history
  • Loading branch information
drpepper committed Sep 26, 2023
1 parent 594eee3 commit 4e6d91d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export interface IEventListener {
subscriptionHandler: SubscriptionHandler;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type SignalParams = Record<string, any>;

/**
* A `Signal` represents a immutable message that is provided to a chip when it activates,
* as well as when it terminates.
Expand All @@ -95,11 +98,13 @@ export interface IEventListener {
*/
export interface Signal {
readonly name: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly params: Record<string, any>;
readonly params: SignalParams;
}

export function makeSignal(name = "default", params = {}): Signal {
export function makeSignal(
name = "default",
params: SignalParams = {}
): Signal {
return { name, params };
}

Expand Down

0 comments on commit 4e6d91d

Please sign in to comment.