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 data provider packages export non-strict types #9970

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Jul 2, 2024

Since third-party data providers stem from ours, we should provide data providers that compile with strictNullChecks

@@ -35,14 +35,17 @@ import { fetchUtils, DataProvider } from 'ra-core';
*/
export default (apiUrl, httpClient = fetchUtils.fetchJson): DataProvider => ({
getList: (resource, params) => {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const { page, perPage } = params.pagination || {};
Copy link
Member Author

@fzaninotto fzaninotto Jul 2, 2024

Choose a reason for hiding this comment

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

We should have to do the same for getManyReference, except the Params types for the two methods don't match... params are optional in getList and required for getManyReference.

export interface GetListParams {
pagination?: PaginationPayload;
sort?: SortPayload;
filter?: any;
meta?: any;
signal?: AbortSignal;
}

export interface GetManyReferenceParams {
target: string;
id: Identifier;
pagination: PaginationPayload;
sort: SortPayload;
filter: any;
meta?: any;
signal?: AbortSignal;
}

@djhi djhi merged commit 3140979 into master Jul 3, 2024
14 checks passed
@djhi djhi deleted the data-provider-types branch July 3, 2024 07:11
@djhi djhi added this to the 5.0.4 milestone Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants