Skip to content

Commit

Permalink
Remove ComposableController generic type parameters
Browse files Browse the repository at this point in the history
These generic type parameters weren't really used in practice. They
were passed to the `messagingSystem`, but we erased the type of the
messaging system in the one place that we call it, making the more
specific types pointless. You can tell that they weren't useful because
they were never set in tests, and everything still worked.
  • Loading branch information
Gudahtt committed Apr 22, 2021
1 parent 089ae86 commit b1772f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
18 changes: 6 additions & 12 deletions src/ComposableController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import BaseController from './BaseController';
import {
RestrictedControllerMessenger,
EventConstraint,
} from './ControllerMessenger';
import { RestrictedControllerMessenger } from './ControllerMessenger';

/**
* List of child controller instances
Expand All @@ -21,18 +18,15 @@ export type ControllerList = (
/**
* Controller that can be used to compose multiple controllers together
*/
export class ComposableController<
Events extends EventConstraint,
AllowedEvents extends string
> extends BaseController<never, any> {
export class ComposableController extends BaseController<never, any> {
private controllers: ControllerList = [];

private messagingSystem?: RestrictedControllerMessenger<
'ComposableController',
never,
Events,
any,
never,
AllowedEvents
any
>;

/**
Expand All @@ -51,9 +45,9 @@ export class ComposableController<
messenger?: RestrictedControllerMessenger<
'ComposableController',
never,
Events,
any,
never,
AllowedEvents
any
>,
) {
super(
Expand Down
9 changes: 1 addition & 8 deletions src/ControllerMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ type ExtractEventPayload<Event, T> = Event extends { type: T; payload: infer P }
: never;

type ActionConstraint = { type: string; handler: (...args: any) => unknown };

/**
* A valid ControllerMessenger Event.
*
* This type is used to constrain generic Event parameters, to ensure valid
* Event types are given.
*/
export type EventConstraint = { type: string; payload: unknown[] };
type EventConstraint = { type: string; payload: unknown[] };

/**
* A namespaced string
Expand Down

0 comments on commit b1772f2

Please sign in to comment.