Export simple type annotations for function-as-a-child arguments
See original GitHub issueIs your feature request related to a problem? Please describe.
Sometimes it is necessary to pass down methods such as refetch
and mutate
that come from the function-as-a-child arguments of the Get
and Mutate
components, e.g. child component or a component method at which point they need a type annotation. Currently, this is quite hard to reproduce with the mutate API looking something like this: https://github.com/contiamo/restful-react/blob/master/src/Mutate.tsx#L119.
Describe the solution you’d like
The library should export interfaces for these methods taking the number and configuration of generics as the Get
or Mutate
components themselves. This would make type annotations straightforward and easy to follow.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Type annotations for default export · Issue #13626 - GitHub
we have tried to keep the module export as simple as possible on the syntax side. 1
Read more >Understanding type annotation in Python - LogRocket Blog
In this extensive post with specific examples, learn how to use Python type annotation to your advantage using the mypy library.
Read more >How to use class returned by a function in type annotations?
The simple solution is to do the other half of the job, add a type with the same name that will be the...
Read more >Type hints cheat sheet - mypy 0.991 documentation
Type hints cheat sheet#. This document is a quick cheat sheet showing how to use type annotations for various common types in Python....
Read more >Asking for required annotations - Medium
The simplest solution here would be to use an explicit type argument to the OrderedMap() constructor, but any annotation between the exports and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh wow they’re actually the same, never mind I didn’t say anything 😃
The
mutate
argument in the render props pattern can have the following signatures:mutate: (body?: string | {}) => Promise<TData>
mutate: (resourceId?: string | {}) => Promise<TData>
and this is based on whether we are working with
MutateWithDeleteProps
andMutateWithOtherVerbProps
, but we won’t be able to tell statically which one. Therefor my suggestion was to export both annotations and leave it up to the user to use the one that’s relevant to each use-case when this comes up.