actions / toolkit

The GitHub ToolKit for developing GitHub Actions.
https://github.com/features/actions
MIT License
5.01k stars 1.45k forks source link

Property body of WebhookPayload should be string | null not optional #1785

Open DamianKleisinger opened 3 months ago

DamianKleisinger commented 3 months ago

Describe the bug The body property of the WebhookPayload interface should be string | null, not an optional string. https://github.com/actions/toolkit/blob/bb6c50093929116e7050c394da9b9a1eb720d746/packages/github/src/interfaces.ts#L22

To Reproduce

import { PullRequestOpenedEvent } from '@octokit/webhooks-types';
import * as github from '@actions/github';

github.context.payload =  {} as PullRequestOpenedEvent;
/*  TS2322: Type 'PullRequestOpenedEvent' is not assignable to type 'WebhookPayload'.
      Types of property 'pull_request' are incompatible.
        Type 'PullRequest & { state: "open"; closed_at: null; merged_at: null; active_lock_reason: null; merged_by: null; }' is not assignable to type '{ [key: string]: any; number: number; html_url?: string | undefined; body?: string | undefined; } | undefined'.
          Type 'PullRequest & { state: "open"; closed_at: null; merged_at: null; active_lock_reason: null; merged_by: null; }' is not assignable to type '{ [key: string]: any; number: number; html_url?: string | undefined; body?: string | undefined; }'.
            Types of property 'body' are incompatible.
              Type 'string | null' is not assignable to type 'string | undefined'.
                Type 'null' is not assignable to type 'string | undefined'.*/

Expected behavior Typing should be compatible with @octokit/webhooks-definitions