question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export simple type annotations for function-as-a-child arguments

See original GitHub issue

Is 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
peterszerzocommented, Oct 16, 2018

Oh wow they’re actually the same, never mind I didn’t say anything 😃

0reactions
peterszerzocommented, Oct 16, 2018

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 and MutateWithOtherVerbProps, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found