Skip to content
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

Build error: Type '(BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | BaseWebhookEvent<"meta"> | ... 199 more ... | (BaseWebhookEvent<...> & { ...; })) & { ...; }' does not satisfy the constraint 'Options<unknown>'. #212

Closed
gr2m opened this issue Mar 8, 2021 · 4 comments · Fixed by #211
Labels
Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR

Comments

@gr2m
Copy link
Contributor

gr2m commented Mar 8, 2021

This is a follow up to #201 @G-Rath @oscard0m @wolfy1339

I get the following error since yesterdays lock file update which bumped @octokit/webhooks from 8.4.1 to 8.5.3 and @octokit/webhooks-definitions to 3.61.0 to 3.62.5

Any idea what it could be?

error TS2344: Type '(BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | BaseWebhookEvent<"meta"> | ... 199 more ... | (BaseWebhookEvent<...> & { ...; })) & { ...; }' does not satisfy the constraint 'Options<unknown>'.
  Type 'BaseWebhookEvent<"push"> & { octokit: Octokit; }' has no properties in common with type 'Options<unknown>'.

13 ): Webhooks<EmitterWebhookEvent & { octokit: Octokit }> {
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/webhooks.ts:14:3 - error TS2322: Type 'Webhooks<{ secret: string; path: string; transform: (event: BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | ... 200 more ... | (BaseWebhookEvent<...> & { ...; })) => Promise<...>; }>' is not assignable to type 'Webhooks<(BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | BaseWebhookEvent<"meta"> | ... 199 more ... | (BaseWebhookEvent<...> & { ...; })) & { ...; }>'.
  Type '{ secret: string; path: string; transform: (event: BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | ... 200 more ... | (BaseWebhookEvent<...> & { ...; })) => Promise<...>; }' is not assignable to type '(BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | BaseWebhookEvent<"meta"> | ... 199 more ... | (BaseWebhookEvent<...> & { ...; })) & { ...; }'.
    Type '{ secret: string; path: string; transform: (event: BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | ... 200 more ... | (BaseWebhookEvent<...> & { ...; })) => Promise<...>; }' is not assignable to type 'BaseWebhookEvent<"workflow_run"> & { payload: { action: "requested"; }; } & { octokit: Octokit; }'.
      Type '{ secret: string; path: string; transform: (event: BaseWebhookEvent<"push"> | BaseWebhookEvent<"public"> | BaseWebhookEvent<"label"> | ... 200 more ... | (BaseWebhookEvent<...> & { ...; })) => Promise<...>; }' is missing the following properties from type 'BaseWebhookEvent<"workflow_run">': id, name, payload

 14   return new Webhooks({
      ~~~~~~~~~~~~~~~~~~~~~
 15     secret: options.secret,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 57     },
    ~~~~~~
 58   });
    ~~~~~
@gr2m gr2m added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label Mar 9, 2021
@wolfy1339
Copy link
Member

Looking at the changes from octokit/webhooks@v3.61.0...v3.62.5 I don't see anything that would cause issues upstream.

However, when i check the changes from octokit/webhooks.js@v8.4.1...v8.5.3 I do see some refactoring that happened around the type parameters for the Webhooks class, which seems to line up with the build error

@wolfy1339
Copy link
Member

wolfy1339 commented Mar 10, 2021

I believe this diff should do the trick, no errors are reported at build time when I use it:

diff --git a/src/webhooks.ts b/src/webhooks.ts
index 698ebb3..bd9d823 100644
--- a/src/webhooks.ts
+++ b/src/webhooks.ts
@@ -10,7 +10,14 @@ 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<EmitterWebhookEvent & { octokit: Octokit }> {
+): Webhooks<
+  Required<Options>["webhooks"] & {
+    path: "/api/github/webhooks";
+    transform: (
+      event: EmitterWebhookEvent
+    ) => Promise<EmitterWebhookEvent & { octokit: Octokit }>;
+  }
+> {
   return new Webhooks({
     secret: options.secret,
     path: "/api/github/webhooks",

@oscard0m
Copy link
Member

oscard0m commented Mar 12, 2021

For readers with no context:
Issue is happening in this branch: renovate/lock-file-maintenance
Check Run where the issue is happening: https://github.com/octokit/app.js/pull/211/checks?check_run_id=2079497901


Rolling back in local the following changes makes the issue stop happening: https://github.com/octokit/webhooks.js/pull/464/files#diff-621affb8a60ba2e02a5b8043ac16813bc423cec3b8777c30da898bfee140b6ed

@wolfy1339
Copy link
Member

Fixed by octokit/webhooks.js#494

@wolfy1339 wolfy1339 linked a pull request Mar 14, 2021 that will close this issue
1 task
@gr2m gr2m closed this as completed in #211 Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR
Projects
None yet
3 participants