inngest / inngest-js

The developer platform for easily building reliable workflows with zero infrastructure for TypeScript & JavaScript
https://www.inngest.com/
GNU General Public License v3.0
414 stars 41 forks source link

[BUG] type `GetEvents` no longer creates a type that can be used with `inngest.send()` due to exclusion of internal event names in the latter #452

Closed fnimick closed 7 months ago

fnimick commented 8 months ago

Describe the bug Previously, both GetEvents and the SendEventPayload used in inngest.send allowed for internal event types such as inngest/function.finished to be used.

In the latest version, SendEventPayload excludes these, but GetEvents still includes them.

To Reproduce

export const inngest = new Inngest({
  ...
});

export type InngestEventsByKey = GetEvents<typeof inngest>;
export type InngestEvent = InngestEventsByKey[keyof InngestEventsByKey];

function testSend(e: InngestEvent[]) {
  inngest.send(e);
}

Observe that this fails to type-check with Type '"inngest/function.finished"' is not assignable to type....

Expected behavior The return type of GetEvents should match the expected parameter type of inngest.send().

A current workaround is to use WithoutInternal<GetEvents<typeof inngest>> yourself, but this should not be required for client code.

Code snippets / Logs / Screenshots If applicable, add screenshots to help explain your problem.

System info (please complete the following information):

Additional context Add any other context about the problem here.