Skip to content

Commit

Permalink
fix(github): fix typings for new @octokit/webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 10, 2020
1 parent f4cbdae commit 6d46eb0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/plugin-github/src/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable camelcase */

import { EventNames } from '@octokit/webhooks'
import { GetWebhookPayloadTypeFromEvent } from '@octokit/webhooks/dist-types/generated/get-webhook-payload-type-from-event'
import { EventTypesPayload } from '@octokit/webhooks/dist-types/generated/get-webhook-payload-type-from-event'

type WebhookEvent = Exclude<keyof EventTypesPayload, 'error'>

export interface EventConfig {
commitComment?: boolean | {
Expand Down Expand Up @@ -105,10 +106,10 @@ export interface EventData {
}
}

type Payload<T extends EventNames.All> = GetWebhookPayloadTypeFromEvent<T, unknown>['payload']
type EventHandler<T extends EventNames.All> = (payload: Payload<T>) => EventData
type Payload<T extends WebhookEvent> = EventTypesPayload[T]['payload']
type EventHandler<T extends WebhookEvent> = (payload: Payload<T>) => EventData

export function addListeners(on: <T extends EventNames.All>(event: T, handler: EventHandler<T>) => void) {
export function addListeners(on: <T extends WebhookEvent>(event: T, handler: EventHandler<T>) => void) {
function formatMarkdown(source: string) {
return source
.replace(/^```(.*)$/gm, '')
Expand Down

0 comments on commit 6d46eb0

Please sign in to comment.