uncertain-scarletU

[Incorrect Types] Apify JS Client

I am using the API JS client version 2.8.0 to programmatically create a schedule with 1 task action. The code looks like the following

const schedule = await client.schedules().create({
  isEnabled: true,
  cronExpression,
  actions: [
    {
      type: ScheduleActions.RunActorTask,
      actorTaskId: task.id,
    },
  ],
});


However, I get a TS error saying that my action object is missing an id field due to the following interface definition:

interface BaseScheduleAction<Type extends ScheduleActions> {
    id: string;
    type: Type;
}


When I try to supply a value, the operation fails and no task is added but it works when I add a // @ts-ignore statement and omit id entirely. I suspect that the interface definition is incorrect and id should not be required and instead should be generated by Apify. My suspicions are further confirmed by the fact that the network request sent from the client does not include a value for id when adding a task to a schedule in the UI (see attached image)
image.png
Was this page helpful?