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

[TypeScript] Fix missing useMutation error typing definitions #7722

Merged
merged 1 commit into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ const useDeleteWithConfirmController = <RecordType extends RaRecord = any>(
};

export interface UseDeleteWithConfirmControllerParams<
RecordType extends RaRecord = any
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> {
mutationMode?: MutationMode;
record?: RecordType;
Expand All @@ -169,7 +170,7 @@ export interface UseDeleteWithConfirmControllerParams<
onClick?: ReactEventHandler<any>;
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
DeleteParams<RecordType>
>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ const useDeleteWithUndoController = <RecordType extends RaRecord = any>(
};

export interface UseDeleteWithUndoControllerParams<
RecordType extends RaRecord = any
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> {
record?: RecordType;
redirect?: RedirectionSideEffect;
Expand All @@ -126,7 +127,7 @@ export interface UseDeleteWithUndoControllerParams<
onClick?: ReactEventHandler<any>;
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
DeleteParams<RecordType>
>;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/ra-ui-materialui/src/button/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ export const DeleteButton = <RecordType extends RaRecord = any>(
);
};

export interface DeleteButtonProps<RecordType extends RaRecord = any>
extends Omit<ButtonProps, 'record'>,
export interface DeleteButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> extends Omit<ButtonProps, 'record'>,
SaveContextValue {
className?: string;
confirmTitle?: string;
Expand All @@ -94,7 +96,7 @@ export interface DeleteButtonProps<RecordType extends RaRecord = any>
// May be injected by Toolbar
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
DeleteParams<RecordType>
>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(

const defaultIcon = <ActionDelete />;

export interface DeleteWithConfirmButtonProps<RecordType extends RaRecord = any>
extends Omit<ButtonProps, 'record'> {
export interface DeleteWithConfirmButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> extends Omit<ButtonProps, 'record'> {
className?: string;
confirmTitle?: string;
confirmContent?: React.ReactNode;
Expand All @@ -110,7 +112,7 @@ export interface DeleteWithConfirmButtonProps<RecordType extends RaRecord = any>
translateOptions?: object;
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
DeleteParams<RecordType>
>;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/ra-ui-materialui/src/button/DeleteWithUndoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export const DeleteWithUndoButton = <RecordType extends RaRecord = any>(

const defaultIcon = <ActionDelete />;

export interface DeleteWithUndoButtonProps<RecordType extends RaRecord = any>
extends Omit<ButtonProps, 'record'> {
export interface DeleteWithUndoButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> extends Omit<ButtonProps, 'record'> {
className?: string;
icon?: ReactElement;
label?: string;
Expand All @@ -68,7 +70,7 @@ export interface DeleteWithUndoButtonProps<RecordType extends RaRecord = any>
// May be injected by Toolbar - sanitized in Button
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
DeleteParams<RecordType>
>;
}
Expand Down
7 changes: 5 additions & 2 deletions packages/ra-ui-materialui/src/button/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,18 @@ export const SaveButton = <RecordType extends RaRecord = any>(

const defaultIcon = <ContentSave />;

interface Props<RecordType extends RaRecord = any> {
interface Props<
RecordType extends RaRecord = any,
MutationOptionsError = unknown
> {
className?: string;
disabled?: boolean;
icon?: ReactElement;
invalid?: boolean;
label?: string;
mutationOptions?: UseMutationOptions<
RecordType,
unknown,
MutationOptionsError,
CreateParams<RecordType> | UpdateParams<RecordType>
>;
transform?: TransformData;
Expand Down