Skip to content

Commit

Permalink
Improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 27, 2023
1 parent ce4a066 commit bece065
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions types/ext/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ export type ApiNames = BaseApiNames<ApiSurface>;

export type ApiMessageNoFrameId<TName extends ApiNames> = (
ApiParams<TName> extends void ?
{action: TName} :
{action: TName, params?: never} :
{action: TName, params: ApiParams<TName>}
);

export type ApiMessage<TName extends ApiNames> = ApiMessageNoFrameId<TName> & {frameId?: number};
export type ApiMessage<TName extends ApiNames> = ApiMessageNoFrameId<TName> & {
/**
* The origin frameId that sent this message.
* If sent from the backend, this value will be undefined.
*/
frameId?: number;
};

export type ApiMessageNoFrameIdAny = ApiMessageNoFrameId<ApiNames>;
export type ApiMessageNoFrameIdAny = {[name in ApiNames]: ApiMessageNoFrameId<name>}[ApiNames];

export type ApiMessageAny = ApiMessage<ApiNames>;
export type ApiMessageAny = {[name in ApiNames]: ApiMessage<name>}[ApiNames];

export type ApiMap = BaseApiMap<ApiSurface>;

Expand Down

0 comments on commit bece065

Please sign in to comment.