@octokit/webhooks-types
TypeScript icon, indicating that this package has built-in type declarations

7.5.1 • Public • Published

Octokit Webhooks

machine-readable, always up-to-date GitHub Webhooks specifications

Update status

Download

Download the latest specification at octokit.github.io/webhooks/payload-examples/api.github.com/index.json

Usage

This package ships with types for the webhook events generated from the respective json schemas, which you can use like so:

import { WebhookEvent, IssuesOpenedEvent } from "@octokit/webhooks-types";

const handleWebhookEvent = (event: WebhookEvent) => {
  if ("action" in event && event.action === "completed") {
    console.log(`${event.sender.login} completed something!`);
  }
};

const handleIssuesOpenedEvent = (event: IssuesOpenedEvent) => {
  console.log(
    `${event.sender.login} opened "${event.issue.title}" on ${event.repository.full_name}`,
  );
};

⚠️ Caution ⚠️: Webhooks Types are expected to be used with the strictNullChecks option enabled in your tsconfig. If you don't have this option enabled, there's the possibility that you get never as the inferred type in some use cases. See #395 for details.

See also

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @octokit/webhooks-types

Weekly Downloads

520,635

Version

7.5.1

License

MIT

Unpacked Size

222 kB

Total Files

3

Last publish

Collaborators

  • kfcampbell
  • nickfloyd
  • gr2m
  • octokitbot