Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ScheduleUpdateData type #276

Merged
merged 1 commit into from Oct 30, 2023
Merged

fix: ScheduleUpdateData type #276

merged 1 commit into from Oct 30, 2023

Conversation

magne4000
Copy link
Contributor

ScheduleUpdateData enforces id key on actions prop, but it should be optional.

Following snippet should be OK:

await client.schedule(schedule.id).update({
  actions: [{
    type: ScheduleActions.RunActor,
    actorId: 'someId',
  }]
});

But I get this error:

Type '{ type: ScheduleActions.RunActor; actorId: string; }' is not assignable to type 'ScheduleAction'.
  Property 'id' is missing in type '{ type: ScheduleActions.RunActor; actorId: string; }' but required in type 'ScheduleActionRunActor'.ts(2322)
schedule.d.ts(47, 5): 'id' is declared here.

Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this, and super sorry for the fact this got lost!! 💙

@vladfrangu vladfrangu merged commit e59ff10 into apify:master Oct 30, 2023
6 checks passed
B4nan pushed a commit that referenced this pull request Nov 10, 2023
This PR appears to follow-up on
#276 which made it so `id`
was optional ✅ but did so in a way that removed the remainder of the
required fields from the type definition ❌, e.g. `actorTaskId` was no
longer recognized as a valid property as of v2.8.2

Because `ScheduleAction` is defined as a union of different types, we
must use [distributive conditional
types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types)
to capture the specific properties of the individual subtypes correctly.
superman030129 added a commit to superman030129/apify-client-js that referenced this pull request Mar 9, 2024
This PR appears to follow-up on
apify/apify-client-js#276 which made it so `id`
was optional ✅ but did so in a way that removed the remainder of the
required fields from the type definition ❌, e.g. `actorTaskId` was no
longer recognized as a valid property as of v2.8.2

Because `ScheduleAction` is defined as a union of different types, we
must use [distributive conditional
types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types)
to capture the specific properties of the individual subtypes correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants