diff --git a/pages/docs/typescript.mdx b/pages/docs/typescript.mdx index b56c1677c..c17d96c6b 100644 --- a/pages/docs/typescript.mdx +++ b/pages/docs/typescript.mdx @@ -225,3 +225,48 @@ export default inngest.createFunction( ); ``` + +## Helpers + +The TS SDK exports some helper types to allow you to access the type of particular Inngest internals outside of an Inngest function. + +### GetEvents + +Get a record of all available events given an Inngest client. + +It's recommended to use this instead of directly reusing your own event types, as Inngest will add extra properties and internal events such as `ts` and `inngest/function.failed`. + +```ts +import { type GetEvents } from "inngest"; +import { inngest } from "@/inngest"; + +type Events = GetEvents; +``` + +### GetFunctionInput + +Get the argument passed to Inngest functions given an Inngest client and, optionally, an event trigger. + +Useful for building function factories or other such abstractions. + +```ts +import { type GetFunctionInput } from "inngest"; +import { inngest } from "@/inngest"; + +type InputArg = GetFunctionInput; +type InputArgWithTrigger = GetFunctionInput; +``` + +### GetStepTools + +Get the `step` object passed to an Inngest function given an Inngest client and, optionally, an event trigger. + +Is a small shim over the top of `GetFunctionInput<...>["step"]`. + +```ts +import { type GetStepTools } from "inngest"; +import { inngest } from "@/inngest"; + +type StepTools = GetStepTools; +type StepToolsWithTrigger = GetStepTools; +```