-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(typescript): adapt for @octokit/[email protected]
#213
Conversation
e3c6b67
to
42054df
Compare
e3ed69a
to
e2e3d97
Compare
@wolfy1339 it'd be good if you could just enable |
The following lines of code in the tests are erroring (see octokit/webhooks.js#490 as well) app.js/test/readme-examples.test.ts Lines 181 to 191 in b1ab5f7
Error message:
|
Then |
Do you have any idea how to fix the error i mentioned above? |
I can tell you why it's happening: the generic is being destroyed by this:
I honestly don't think it can be solved in its current form - the problem is that |
I'd be okay with enforcing that |
That's be my preference as well as it should make things a lot easier to manage. |
that's music in my ears :) let's do it |
Would this be the approach you were looking for? octokit/webhooks.js#492 |
Does that work? Does it keep the proper event typing? webhooks.on("push", event => {
// event should have type EmitterWebhookEvent<"push"> & { octokit: Octokit }
}); |
I have tried a variance of this patch, setting the types via the generic of the Webhooks class. That didn't work diff --git a/src/webhooks.ts b/src/webhooks.ts
index bd9d823..461615b 100644
--- a/src/webhooks.ts
+++ b/src/webhooks.ts
@@ -10,15 +10,15 @@ export function webhooks(
options: Required<Options>["webhooks"]
// Explict return type for better debugability and performance,
// see https://github.com/octokit/app.js/pull/201
-): Webhooks<
- Required<Options>["webhooks"] & {
- path: "/api/github/webhooks";
- transform: (
- event: EmitterWebhookEvent
- ) => Promise<EmitterWebhookEvent & { octokit: Octokit }>;
- }
-> {
- return new Webhooks({
+) {
+ return new Webhooks<
+ Required<Options>["webhooks"] & {
+ path: "/api/github/webhooks";
+ transform: (
+ event: EmitterWebhookEvent
+ ) => Promise<EmitterWebhookEvent & { octokit: Octokit }>;
+ }
+ >({
secret: options.secret,
path: "/api/github/webhooks",
transform: async (event) => { So then I tried removing all the explicit types, and then that didn't work either. |
I really appreciate you looking into this. Thank you so much! |
This PR will not be necessary once octokit/webhooks.js#494 is merged |
This patch fixes #212, however it currently breaks the automatic type inferance for event payloads, thus making the tests fail