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

Extending data providers in react-admin v3 with typescript #4340

Closed
g3n35i5 opened this issue Jan 22, 2020 · 4 comments · Fixed by #4341
Closed

Extending data providers in react-admin v3 with typescript #4340

g3n35i5 opened this issue Jan 22, 2020 · 4 comments · Fixed by #4341

Comments

@g3n35i5
Copy link
Contributor

g3n35i5 commented Jan 22, 2020

I'm not sure if this is a bug or a wrong implementation on my part. I have already described the problem in detail on stackoverflow.
For this reason I will give only a shortened description here.

What you were expecting:
I want to extend the simple rest provider with my own update method.

What happened instead:
I get the following error:
Property 'update' does not exist on type '(apiUrl: any, httpClient?: ((url: any, options?: Options | undefined) => Promise<{ status: number; headers: Headers; body: string; json: any; }>) | undefined) => DataProvider'. TS2339

Steps to reproduce:
I followed the steps as explained in the documentation

Environment

  • React-admin version: 3.1.2
  • React version: 16.12.0
  • Browser: Chromium
  • Stack trace (in case of a JS error):
Property 'update' does not exist on type '(apiUrl: any, httpClient?: ((url: any, options?: Options | undefined) => Promise<{ status: number; headers: Headers; body: string; json: any; }>) | undefined) => DataProvider'.  TS2339

   6 |         if (resource !== 'posts' || !params.data.pictures) {
   7 |             // fallback to the default implementation
>  8 |             return dataProvider.update(resource, params);
     |                                 ^
   9 |         }
  10 |         /**
  11 |          * For posts update only, convert uploaded image in base 64 and attach it to
@fzaninotto
Copy link
Member

This is not bug, check the documentation or wait for someone to give you a hand on StackOverflow.

@g3n35i5
Copy link
Contributor Author

g3n35i5 commented Jan 22, 2020

@fzaninotto First of all, thank you for your answer. Could you briefly explain to me why it is not a bug (or faulty or incomplete documentation) if I took the code from the documentation without any changes and it does not work?

@fzaninotto
Copy link
Member

Sorry, you're right, the documentation is wrong. I'll mark it as a documentation bug.

@g3n35i5
Copy link
Contributor Author

g3n35i5 commented Jan 22, 2020

Great, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants