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

[BUG]: Typerror in app.webhooks.on #2761

Closed
1 task done
corsin-ragettli opened this issue Nov 19, 2024 · 2 comments
Closed
1 task done

[BUG]: Typerror in app.webhooks.on #2761

corsin-ragettli opened this issue Nov 19, 2024 · 2 comments
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@corsin-ragettli
Copy link

corsin-ragettli commented Nov 19, 2024

What happened?

This code will produce an error in typescript:

import { App } from "octokit";
import type {
  PullRequestClosedEvent,
} from "@octokit/webhooks-types";

const app = new App({
  appId: GH_APP_ID,
  privateKey: GH_PRIVATE_KEY
})

function handlePullRequestClosed(payload: PullRequestClosedEvent) {}

app.webhooks.on("pull_request.closed", ({ payload }) =>
  handleClosedPullRequest(payload)
);

The following error will be thrown:

Argument of type '{ action: "closed"; installation?: { id: number; node_id: string; } | undefined; number: number; organization?: { login: string; id: number; node_id: string; url: string; repos_url: string; events_url: string; ... 5 more ...; description: string | null; } | undefined; pull_request: { ...; } & { ...; }; repository: {...' is not assignable to parameter of type 'PullRequestClosedEvent'.
  Types of property 'pull_request' are incompatible.
    Type '{ url: string; id: number; node_id: string; html_url: string; diff_url: string; patch_url: string; issue_url: string; commits_url: string; review_comments_url: string; review_comment_url: string; ... 37 more ...; changed_files: number; } & { ...; }' is not assignable to type 'PullRequest & { state: "closed"; closed_at: string; merged: boolean; }'.
      Type '{ url: string; id: number; node_id: string; html_url: string; diff_url: string; patch_url: string; issue_url: string; commits_url: string; review_comments_url: string; review_comment_url: string; ... 37 more ...; changed_files: number; } & { ...; }' is not assignable to type 'PullRequest'.
        The types of 'user.name' are incompatible between these types.
          Type 'string | null | undefined' is not assignable to type 'string | undefined'.
            Type 'null' is not assignable to type 'string | undefined'.ts(2345)

Please remove the null type from the user.name union, or make the types otherwise compatible

Versions

Oktokit.js 4.0.2, Node v20.18.0, Typescript 5.6.3, @octokit/webhook-types 7.6.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@corsin-ragettli corsin-ragettli added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Nov 19, 2024
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@corsin-ragettli corsin-ragettli changed the title [BUG]: [BUG]: Typerror in app.webhooks.on Nov 19, 2024
@wolfy1339 wolfy1339 added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Type: Bug Something isn't working as documented Status: Triage This is being looked at and prioritized labels Nov 19, 2024
@wolfy1339
Copy link
Member

Hi, this is an error with your code.

You are using the wrong types. The types you are using is not compatible with the version of Octokit you are running.

You need to use the @octokit/openapi-webhooks-types package.

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2024
@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
Status: Done
Development

No branches or pull requests

2 participants