Skip to content

Commit

Permalink
fix: union too complex solve
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Jun 10, 2024
1 parent 4169a83 commit 39cd3e8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/github/github-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import { EmitterWebhookEvent as WebhookEvent, EmitterWebhookEventName as Webhook
import { customOctokit } from "./github-client";
import { GitHubEventHandler } from "./github-event-handler";

export class GitHubContext<T extends WebhookEventName = WebhookEventName> {
export type SupportedEventsU = WebhookEventName;

export type SupportedEvents = {
[K in SupportedEventsU]: K extends WebhookEventName ? WebhookEvent<K> : never;
};

export class GitHubContext<T extends SupportedEventsU = SupportedEventsU, TU extends SupportedEvents[T] = SupportedEvents[T]> {
public key: WebhookEventName;
public name: WebhookEventName;
public id: string;
public payload: WebhookEvent<T>["payload"];
public payload: TU["payload"];
public octokit: InstanceType<typeof customOctokit>;
public eventHandler: InstanceType<typeof GitHubEventHandler>;

constructor(eventHandler: InstanceType<typeof GitHubEventHandler>, event: WebhookEvent<T>, octokit: InstanceType<typeof customOctokit>) {
constructor(eventHandler: InstanceType<typeof GitHubEventHandler>, event: TU, octokit: InstanceType<typeof customOctokit>) {
this.eventHandler = eventHandler;
this.name = event.name;
this.id = event.id;
Expand Down

0 comments on commit 39cd3e8

Please sign in to comment.