Skip to content

Commit d7ebf10

Browse files
committed
fix(typescript): export Webhooks explicitly
This is how we do it in @octokit/rest. I don’t know if that’s the right way to do it, but this change was necessary in order to get probot/probot#832 to work
1 parent 79fcec2 commit d7ebf10

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

scripts/generate-types.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,26 @@ export namespace Webhooks {
5151
host?: string
5252
url?: string
5353
}
54-
export class Webhooks {
55-
constructor (options: Options)
54+
}
5655
57-
public on (event: 'error', callback: (event: Error) => void): void
58-
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
59-
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
60-
${signatures.join('\n')}
56+
export class Webhooks {
57+
constructor (options: Options)
6158
62-
public sign (data: any): string
63-
public verify (eventPayload: any, signature: string): boolean
64-
public verifyAndReceive (options: { id: string, name: string, payload: any, signature: string }): Promise<void>
65-
public receive (options: { id: string, name: string, payload: any }): Promise<void>
66-
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
67-
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
68-
public middleware (request: http.ClientRequest, response: http.ServerResponse, next: (err?: any) => void): (request: http.IncomingMessage, response: http.ServerResponse) => void
69-
}
59+
public on (event: 'error', callback: (event: Error) => void): void
60+
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
61+
public on (event: '*' | string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
62+
${signatures.join('\n')}
63+
64+
public sign (data: any): string
65+
public verify (eventPayload: any, signature: string): boolean
66+
public verifyAndReceive (options: { id: string, name: string, payload: any, signature: string }): Promise<void>
67+
public receive (options: { id: string, name: string, payload: any }): Promise<void>
68+
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => void): void
69+
public removeListener (event: string | string[], callback: (event: Webhooks.WebhookEvent<any>) => Promise<void>): void
70+
public middleware (request: http.ClientRequest, response: http.ServerResponse, next: (err?: any) => void): (request: http.IncomingMessage, response: http.ServerResponse) => void
7071
}
72+
73+
export = Webhooks
7174
`
7275

7376
const filepath = 'index.d.ts'

0 commit comments

Comments
 (0)