Skip to content

[Proposal] [TypeScript] prefer interface to conditional types #250

@shigma

Description

@shigma
interface PayloadMap {
  'check_run': WebhookPayloadCheckRun
  'check_run.completed': WebhookPayloadCheckRun
  ...
}

type AllEvents = keyof PayloadMap | 'error' | '*'

export declare type GetWebhookPayloadTypeFromEvent<E = AllEvents, T = WebhookEvent> =
  E extends 'error' ? WebhookEventHandlerError :
  E extends '*' ? any :
  WebhookEvent<PayloadMap[E]> & T

This will not only help reduce dist size but also optimize type check performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: MaintenanceAny dependency, housekeeping, and clean up Issue or PRtypescriptRelevant to TypeScript users only

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions