Skip to content

Commit

Permalink
Fix types for hooks (#4905)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi authored Feb 21, 2021
1 parent 8bf63d5 commit 29e7879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-ducks-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/types': patch
---

Fixed typing for `afterDelete` or `beforeDelete` hooks. Also added type for `updatedItem` in the `afterChange` or `beforeChange` hook
6 changes: 4 additions & 2 deletions packages-next/types/src/config/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type ListHooks<TGeneratedListTypes extends BaseGeneratedListTypes> = {
/**
* Used to **cause side effects** after a delete operation operation has occurred
*/
afterDelete?: BeforeOrAfterChangeHook<TGeneratedListTypes>;
afterDelete?: BeforeOrAfterDeleteHook<TGeneratedListTypes>;
};

type ArgsForCreateOrUpdateOperation<TGeneratedListTypes extends BaseGeneratedListTypes> = (
Expand Down Expand Up @@ -92,7 +92,9 @@ type ValidateInputHook<TGeneratedListTypes extends BaseGeneratedListTypes> = (
) => Promise<void> | void;

type BeforeOrAfterChangeHook<TGeneratedListTypes extends BaseGeneratedListTypes> = (
args: ArgsForCreateOrUpdateOperation<TGeneratedListTypes>
args: ArgsForCreateOrUpdateOperation<TGeneratedListTypes> & {
updatedItem: TGeneratedListTypes['inputs']['create'] | TGeneratedListTypes['inputs']['update'];
}
) => Promise<void> | void;

type ArgsForDeleteOperation<TGeneratedListTypes extends BaseGeneratedListTypes> = {
Expand Down

1 comment on commit 29e7879

@vercel
Copy link

@vercel vercel bot commented on 29e7879 Feb 21, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.