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] TypeScript does not allow "inngest/function.failed" for event key #454

Closed gwax closed 7 months ago

gwax commented 8 months ago

Describe the bug When attempting to add a generic failure handler, typescript refuses to accept "inngest/function.failed" as an event key.

To Reproduce Create a new inngest:

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

Attempt to construct a failure handler per the documentation

const failureHandler = inngest.createFunction(
  { id: "failure-handler", name: "failure handler" },
  { event: "inngest/function.failed" },  // <- Type '"inngest/function.failed"' is not assignable to type 'internalEvents.FunctionFailed | internalEvents.FunctionFinished |
  async () => {},
);

It works fine, if we reference the enum directly but that doesn't match the documentation and requires the use of a variable called internal

const failureHandler = inngest.createFunction(
  { id: "failure-handler", name: "failure handler" },
  { event: internalEvents.FunctionFailed },  // <- No error
  async () => {},
);

Expected behavior No type error when specifying { event: "inngest/function.failed" },

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.