From 00eba7c70e72e584c1ca76834619be33d6a90440 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Fri, 20 May 2022 11:28:09 +0200 Subject: [PATCH] fix(typescript): missing use mutation error typing definition --- .../controller/button/useDeleteWithConfirmController.tsx | 5 +++-- .../src/controller/button/useDeleteWithUndoController.tsx | 5 +++-- packages/ra-ui-materialui/src/button/DeleteButton.tsx | 8 +++++--- .../src/button/DeleteWithConfirmButton.tsx | 8 +++++--- .../ra-ui-materialui/src/button/DeleteWithUndoButton.tsx | 8 +++++--- packages/ra-ui-materialui/src/button/SaveButton.tsx | 7 +++++-- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx b/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx index 5fec393ab4e..df5fd83c971 100644 --- a/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx +++ b/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx @@ -159,7 +159,8 @@ const useDeleteWithConfirmController = ( }; export interface UseDeleteWithConfirmControllerParams< - RecordType extends RaRecord = any + RecordType extends RaRecord = any, + MutationOptionsError = unknown > { mutationMode?: MutationMode; record?: RecordType; @@ -169,7 +170,7 @@ export interface UseDeleteWithConfirmControllerParams< onClick?: ReactEventHandler; mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, DeleteParams >; } diff --git a/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx b/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx index 61348fc2086..2b1f6e2117c 100644 --- a/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx +++ b/packages/ra-core/src/controller/button/useDeleteWithUndoController.tsx @@ -117,7 +117,8 @@ const useDeleteWithUndoController = ( }; export interface UseDeleteWithUndoControllerParams< - RecordType extends RaRecord = any + RecordType extends RaRecord = any, + MutationOptionsError = unknown > { record?: RecordType; redirect?: RedirectionSideEffect; @@ -126,7 +127,7 @@ export interface UseDeleteWithUndoControllerParams< onClick?: ReactEventHandler; mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, DeleteParams >; } diff --git a/packages/ra-ui-materialui/src/button/DeleteButton.tsx b/packages/ra-ui-materialui/src/button/DeleteButton.tsx index 477cf4ecfde..2a7fdec0bd2 100644 --- a/packages/ra-ui-materialui/src/button/DeleteButton.tsx +++ b/packages/ra-ui-materialui/src/button/DeleteButton.tsx @@ -79,8 +79,10 @@ export const DeleteButton = ( ); }; -export interface DeleteButtonProps - extends Omit, +export interface DeleteButtonProps< + RecordType extends RaRecord = any, + MutationOptionsError = unknown +> extends Omit, SaveContextValue { className?: string; confirmTitle?: string; @@ -94,7 +96,7 @@ export interface DeleteButtonProps // May be injected by Toolbar mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, DeleteParams >; } diff --git a/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx b/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx index 1d7918cb32b..8e0632f0545 100644 --- a/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx +++ b/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx @@ -94,8 +94,10 @@ export const DeleteWithConfirmButton = ( const defaultIcon = ; -export interface DeleteWithConfirmButtonProps - extends Omit { +export interface DeleteWithConfirmButtonProps< + RecordType extends RaRecord = any, + MutationOptionsError = unknown +> extends Omit { className?: string; confirmTitle?: string; confirmContent?: React.ReactNode; @@ -110,7 +112,7 @@ export interface DeleteWithConfirmButtonProps translateOptions?: object; mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, DeleteParams >; } diff --git a/packages/ra-ui-materialui/src/button/DeleteWithUndoButton.tsx b/packages/ra-ui-materialui/src/button/DeleteWithUndoButton.tsx index 1f1429748f8..08cc0656cb3 100644 --- a/packages/ra-ui-materialui/src/button/DeleteWithUndoButton.tsx +++ b/packages/ra-ui-materialui/src/button/DeleteWithUndoButton.tsx @@ -56,8 +56,10 @@ export const DeleteWithUndoButton = ( const defaultIcon = ; -export interface DeleteWithUndoButtonProps - extends Omit { +export interface DeleteWithUndoButtonProps< + RecordType extends RaRecord = any, + MutationOptionsError = unknown +> extends Omit { className?: string; icon?: ReactElement; label?: string; @@ -68,7 +70,7 @@ export interface DeleteWithUndoButtonProps // May be injected by Toolbar - sanitized in Button mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, DeleteParams >; } diff --git a/packages/ra-ui-materialui/src/button/SaveButton.tsx b/packages/ra-ui-materialui/src/button/SaveButton.tsx index a6ee93fc36b..9bd101a74ad 100644 --- a/packages/ra-ui-materialui/src/button/SaveButton.tsx +++ b/packages/ra-ui-materialui/src/button/SaveButton.tsx @@ -143,7 +143,10 @@ export const SaveButton = ( const defaultIcon = ; -interface Props { +interface Props< + RecordType extends RaRecord = any, + MutationOptionsError = unknown +> { className?: string; disabled?: boolean; icon?: ReactElement; @@ -151,7 +154,7 @@ interface Props { label?: string; mutationOptions?: UseMutationOptions< RecordType, - unknown, + MutationOptionsError, CreateParams | UpdateParams >; transform?: TransformData;