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

Incorrect type for queryOptions in ReferenceArrayField #10379

Closed
dricholm opened this issue Nov 25, 2024 · 2 comments · Fixed by #10389
Closed

Incorrect type for queryOptions in ReferenceArrayField #10379

dricholm opened this issue Nov 25, 2024 · 2 comments · Fixed by #10389

Comments

@dricholm
Copy link
Contributor

What you were expecting:
Passing the queryOptions prop to ReferenceArrayField should not require the queryKey property.

What happened instead:
Typescript error:

Property 'queryKey' is missing in type '{}' but required in type 'UseQueryOptions<RaRecord<Identifier>[], Error, RaRecord<Identifier>[], QueryKey>'.ts(2741)

Steps to reproduce:
Have a ReferenceArrayField component and specify queryOptions without queryKey for it.

Related code:

<ReferenceArrayField
  queryOptions={{ }}
  reference='resourceName'
  source='referenceIds'>

Other information:

The component passes queyOptions to useReferenceArrayFieldController, which uses the correct type by omitting the "forbidden" fields:

queryOptions?: Omit<
  UseQueryOptions<ReferenceRecordType[]>,
  'queryFn' | 'queryKey'
>;

Environment

  • React-admin version: 5.3.3
  • Last version that did not exhibit the issue (if applicable): Unsure, I believe the prop was added ~1 year ago to the component
  • React version: 18.3.1
  • Browser: Chrome
  • Stack trace (in case of a JS error): -
@fzaninotto
Copy link
Member

Well spotted. Would you like to open a PR to fix it?

@dricholm
Copy link
Contributor Author

Well spotted. Would you like to open a PR to fix it?

Sure, I can open one probably sometime this week.

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 a pull request may close this issue.

2 participants