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

[Doc] Update exporter usage #5771

Closed
wants to merge 1 commit into from
Closed

Conversation

ohbarye
Copy link
Contributor

@ohbarye ohbarye commented Jan 14, 2021

For https://marmelab.com/react-admin/doc/3.10/List.html#exporter

According to the type definition, Exporter is a function that returns Promise<void>.

# https://github.com/marmelab/react-admin/blob/9cc5e83252455b5e3e172306419431716f17a057/packages/ra-core/src/types.ts#L492-L501
export type Exporter = (
    data: any,
    fetchRelatedRecords: (
        data: any,
        field: string,
        resource: string
    ) => Promise<any>,
    dataProvider: DataProvider,
    resource?: string
) => Promise<void>;

And jsonexport that used in the example is a function that returns void.
So the example's return value does not match Exporter type without wrapping with Promise.

# https://github.com/DefinitelyTyped/DefinitelyTyped/blob/40e88087e9ec5898250644da6e4653888905bd85/types/jsonexport/index.d.ts#L112-L116
declare function jsonexport(
    json: object | object[],
    userOptions: jsonexport.UserOptionsWithHandlers,
    cb: (err: Error, csv: string) => void,
): void;

According to the type definition, `Exporter` is a function that returns `Promise<void>`.

```ts
# https://github.com/marmelab/react-admin/blob/9cc5e83252455b5e3e172306419431716f17a057/packages/ra-core/src/types.ts#L492-L501
export type Exporter = (
    data: any,
    fetchRelatedRecords: (
        data: any,
        field: string,
        resource: string
    ) => Promise<any>,
    dataProvider: DataProvider,
    resource?: string
) => Promise<void>;
```

And `jsonexport` that used in the example is a function that returns `void`.
So the example's return value does not match `Exporter` type without wrapping with `Promise`.

```ts
# https://github.com/DefinitelyTyped/DefinitelyTyped/blob/40e88087e9ec5898250644da6e4653888905bd85/types/jsonexport/index.d.ts#L112-L116
declare function jsonexport(
    json: object | object[],
    userOptions: jsonexport.UserOptionsWithHandlers,
    cb: (err: Error, csv: string) => void,
): void;
```
@fzaninotto
Copy link
Member

The type definition is wrong. the return type should be void|Promise<void>. Would you like to change it instead?

ohbarye added a commit to ohbarye/react-admin that referenced this pull request Jan 15, 2021
@ohbarye
Copy link
Contributor Author

ohbarye commented Jan 15, 2021

Got it, thanks. Could you check #5782 instead?

@ohbarye ohbarye closed this Jan 15, 2021
@ohbarye ohbarye deleted the patch-1 branch January 15, 2021 01:34
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.

2 participants