You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the barebones task function to define a task, and specifying the type of the payload parameter to the run function using a type definition, defining any of the lifecycle hooks before the run function leads to a type error. For example, this works fine:
exportconstexampleTask=task({id: "example-task",run: async(payload: {foobar: string})=>{console.log("Hello, world from the run function",{ payload });},onStart: async({ payload })=>{console.log(`payload.foobar: ${payload.foobar}`);},});
Adding the 2nd argument to the run function breaks types:
But only when the lifecycle hook is above the run function. Moving it below fixes the types:
exportconstexampleTask=task({id: "example-task",run: async(payload: {foobar: string},{ ctx })=>{console.log("Hello, world from the run function",{ payload });},onStart: async({ payload })=>{console.log(`payload.foobar: ${payload.foobar}`);},});