Skip to content
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
2 changes: 1 addition & 1 deletion docs/useCreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ const createPost = async () => {

## TypeScript

The `useCreate` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useCreate` hook accepts a generic parameter for the record type and another for the error type:

```tsx
type Product = {
Expand Down
2 changes: 1 addition & 1 deletion docs/useDelete.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DeleteButton = () => {

## TypeScript

The `useDelete` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useDelete` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useDelete<Product, Error>(undefined, undefined, {
Expand Down
2 changes: 1 addition & 1 deletion docs/useDeleteMany.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const BulkDeletePostsButton = () => {

## TypeScript

The `useDeleteMany` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useDeleteMany` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useDeleteMany<Product, Error>(undefined, undefined, {
Expand Down
2 changes: 1 addition & 1 deletion docs/useUpdateMany.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const BulkResetViewsButton = () => {

## TypeScript

The `useUpdateMany` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useUpdateMany` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useUpdateMany<Product, Error>(undefined, undefined, {
Expand Down
2 changes: 1 addition & 1 deletion docs_headless/src/content/docs/useCreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const createPost = async () => {

## TypeScript

The `useCreate` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useCreate` hook accepts a generic parameter for the record type and another for the error type:

```tsx
type Product = {
Expand Down
2 changes: 1 addition & 1 deletion docs_headless/src/content/docs/useDelete.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const DeleteButton = () => {

## TypeScript

The `useDelete` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useDelete` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useDelete<Product, Error>(undefined, undefined, {
Expand Down
2 changes: 1 addition & 1 deletion docs_headless/src/content/docs/useDeleteMany.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const BulkDeletePostsButton = () => {

## TypeScript

The `useDeleteMany` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useDeleteMany` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useDeleteMany<Product, Error>(undefined, undefined, {
Expand Down
2 changes: 1 addition & 1 deletion docs_headless/src/content/docs/useUpdateMany.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const BulkResetViewsButton = () => {

## TypeScript

The `useUpdateMany` hook accepts a generic parameter for the record type and another for the error type (which defaults to `Error`):
The `useUpdateMany` hook accepts a generic parameter for the record type and another for the error type:

```tsx
useUpdateMany<Product, Error>(undefined, undefined, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const useBulkDeleteController = <

export interface UseBulkDeleteControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> {
mutationMode?: MutationMode;
mutationOptions?: UseDeleteManyOptions<RecordType, MutationOptionsError>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useBulkUpdateController = <

export interface UseBulkUpdateControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> {
/* @deprecated use mutationOptions instead */
onSuccess?: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const useDeleteController = <

export interface UseDeleteControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> {
mutationMode?: MutationMode;
mutationOptions?: UseDeleteOptions<RecordType, MutationOptionsError>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const useDeleteWithConfirmController = <

export interface UseDeleteWithConfirmControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends UseDeleteControllerParams<RecordType, MutationOptionsError> {
onClick?: ReactEventHandler<any>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const useDeleteWithUndoController = <

export interface UseDeleteWithUndoControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends Omit<
UseDeleteControllerParams<RecordType, MutationOptionsError>,
'mutationMode'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const useUpdateController = <

export interface UseUpdateControllerParams<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> {
mutationMode?: MutationMode;
mutationOptions?: UseUpdateOptions<RecordType, MutationOptionsError>;
Expand Down
17 changes: 0 additions & 17 deletions packages/ra-core/src/dataProvider/useCreate.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,3 @@ describe('useCreate', () => {
await screen.findByText('3: New Post');
});
});

/**
* Type-level check: the error type defaults to Error, so callbacks don't
* require a cast. See https://github.com/marmelab/react-admin/issues/11262
*/
const _useCreateErrorTypeCheck = () => {
const [create] = useCreate<{ title: string }>();
create(
'posts',
{ data: { title: 'Hello' } },
{ onError: error => error.message }
);
useCreate<{ title: string }>('posts', undefined, {
onError: error => error.message,
onSettled: (_data, error) => error?.message,
});
};
8 changes: 4 additions & 4 deletions packages/ra-core/src/dataProvider/useCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import {
*/
export const useCreate = <
RecordType extends Omit<RaRecord, 'id'> = any,
MutationError = Error,
MutationError = unknown,
ResultRecordType extends RaRecord = RecordType & { id: Identifier },
>(
resource?: string,
Expand Down Expand Up @@ -279,7 +279,7 @@ export interface UseCreateMutateParams<

export type UseCreateOptions<
RecordType extends Omit<RaRecord, 'id'> = any,
MutationError = Error,
MutationError = unknown,
ResultRecordType extends RaRecord = RecordType & { id: Identifier },
> = Omit<
UseMutationOptions<
Expand Down Expand Up @@ -307,7 +307,7 @@ export type UseCreateOptions<
export type CreateMutationFunction<
RecordType extends Omit<RaRecord, 'id'> = any,
TReturnPromise extends boolean = boolean,
MutationError = Error,
MutationError = unknown,
ResultRecordType extends RaRecord = RecordType & { id: Identifier },
> = (
resource?: string,
Expand All @@ -323,7 +323,7 @@ export type CreateMutationFunction<
export type UseCreateResult<
RecordType extends Omit<RaRecord, 'id'> = any,
TReturnPromise extends boolean = boolean,
MutationError = Error,
MutationError = unknown,
ResultRecordType extends RaRecord = RecordType & { id: Identifier },
> = [
CreateMutationFunction<
Expand Down
13 changes: 0 additions & 13 deletions packages/ra-core/src/dataProvider/useDelete.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,3 @@ describe('useDelete', () => {
});
});
});

/**
* Type-level check: the error type defaults to Error, so callbacks don't
* require a cast. See https://github.com/marmelab/react-admin/issues/11262
*/
const _useDeleteErrorTypeCheck = () => {
const [deleteOne] = useDelete<{ id: number }>();
deleteOne('posts', { id: 1 }, { onError: error => error.message });
useDelete<{ id: number }>('posts', undefined, {
onError: error => error.message,
onSettled: (_data, error) => error?.message,
});
};
6 changes: 3 additions & 3 deletions packages/ra-core/src/dataProvider/useDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import { useEvent } from '../util';
*/
export const useDelete = <
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
>(
resource?: string,
params: Partial<DeleteParams<RecordType>> = {},
Expand Down Expand Up @@ -286,7 +286,7 @@ export interface UseDeleteMutateParams<RecordType extends RaRecord = any> {

export type UseDeleteOptions<
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
> = Omit<
UseMutationOptions<
RecordType,
Expand All @@ -304,7 +304,7 @@ export type UseDeleteOptions<

export type UseDeleteResult<
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
TReturnPromise extends boolean = boolean,
> = [
(
Expand Down
13 changes: 0 additions & 13 deletions packages/ra-core/src/dataProvider/useDeleteMany.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,3 @@ describe('useDeleteMany', () => {
});
});
});

/**
* Type-level check: the error type defaults to Error, so callbacks don't
* require a cast. See https://github.com/marmelab/react-admin/issues/11262
*/
const _useDeleteManyErrorTypeCheck = () => {
const [deleteMany] = useDeleteMany<{ id: number }>();
deleteMany('posts', { ids: [1] }, { onError: error => error.message });
useDeleteMany<{ id: number }>('posts', undefined, {
onError: error => error.message,
onSettled: (_data, error) => error?.message,
});
};
6 changes: 3 additions & 3 deletions packages/ra-core/src/dataProvider/useDeleteMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import {
*/
export const useDeleteMany = <
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
>(
resource?: string,
params: Partial<DeleteManyParams<RecordType>> = {},
Expand Down Expand Up @@ -309,7 +309,7 @@ export interface UseDeleteManyMutateParams<RecordType extends RaRecord = any> {

export type UseDeleteManyOptions<
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
TReturnPromise extends boolean = boolean,
> = Omit<
UseMutationOptions<
Expand All @@ -328,7 +328,7 @@ export type UseDeleteManyOptions<

export type UseDeleteManyResult<
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
TReturnPromise extends boolean = boolean,
> = [
(
Expand Down
17 changes: 0 additions & 17 deletions packages/ra-core/src/dataProvider/useUpdateMany.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -788,20 +788,3 @@ describe('useUpdateMany', () => {
afterEach(() => {
jest.restoreAllMocks();
});

/**
* Type-level check: the error type defaults to Error, so callbacks don't
* require a cast. See https://github.com/marmelab/react-admin/issues/11262
*/
const _useUpdateManyErrorTypeCheck = () => {
const [updateMany] = useUpdateMany<{ id: number; title: string }>();
updateMany(
'posts',
{ ids: [1], data: { title: 'Hello' } },
{ onError: error => error.message }
);
useUpdateMany<{ id: number; title: string }>('posts', undefined, {
onError: error => error.message,
onSettled: (_data, error) => error?.message,
});
};
6 changes: 3 additions & 3 deletions packages/ra-core/src/dataProvider/useUpdateMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import { useEvent } from '../util';
*/
export const useUpdateMany = <
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
>(
resource?: string,
params: Partial<UpdateManyParams<Partial<RecordType>>> = {},
Expand Down Expand Up @@ -303,7 +303,7 @@ export interface UseUpdateManyMutateParams<RecordType extends RaRecord = any> {

export type UseUpdateManyOptions<
RecordType extends RaRecord = any,
MutationError = Error,
MutationError = unknown,
> = Omit<
UseMutationOptions<
Array<RecordType['id']>,
Expand All @@ -330,7 +330,7 @@ export type UseUpdateManyOptions<
export type UseUpdateManyResult<
RecordType extends RaRecord = any,
TReturnPromise extends boolean = boolean,
MutationError = Error,
MutationError = unknown,
> = [
(
resource?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const sanitizeRestProps = ({

export interface BulkDeleteWithConfirmButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends ButtonProps,
UseBulkDeleteControllerParams<RecordType, MutationOptionsError> {
confirmContent?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const sanitizeRestProps = ({

export interface BulkDeleteWithUndoButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends ButtonProps,
Omit<
UseBulkDeleteControllerParams<RecordType, MutationOptionsError>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const sanitizeRestProps = ({

export interface BulkUpdateWithConfirmButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends Omit<ButtonProps, 'onError'>,
UseBulkUpdateControllerParams<RecordType, MutationOptionsError> {
confirmContent?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const sanitizeRestProps = ({

export interface BulkUpdateWithUndoButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends Omit<ButtonProps, 'onError'>,
Omit<
UseBulkUpdateControllerParams<RecordType, MutationOptionsError>,
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/button/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const DeleteButton = React.forwardRef(function DeleteButton<

export type DeleteButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> = SaveContextValue &
(
| ({ mutationMode?: 'undoable' } & DeleteWithUndoButtonProps<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const defaultIcon = <ActionDelete />;

export interface DeleteWithConfirmButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends ButtonProps,
UseDeleteControllerParams<RecordType, MutationOptionsError> {
confirmTitle?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const defaultIcon = <ActionDelete />;

export interface DeleteWithUndoButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends ButtonProps,
UseDeleteControllerParams<RecordType, MutationOptionsError> {
icon?: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/button/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const defaultIcon = <ContentSave />;

interface Props<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> {
className?: string;
disabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const sanitizeRestProps = ({

export interface UpdateWithUndoButtonProps<
RecordType extends RaRecord = any,
MutationOptionsError = Error,
MutationOptionsError = unknown,
> extends ButtonProps,
Omit<
UseUpdateControllerParams<RecordType, MutationOptionsError>,
Expand Down
Loading