Answer the question
In order to leave comments, you need to log in
How to get the names of functions from an object that is the result of executing a function?
Hello!
I have a question about TS.
There is a hook in which I pass a function, the call of which returns an object with functions. The hook must return this object to the component. When destructuring this object, I wanted to auto-complete these functions (different functions are passed to the hook, so the set of functions that should be displayed is different).
How can I implement this?
I searched, but did not find (Here is the minimal (or not so) code: https://codesandbox.io/s/objective-cloud-5qz1f
I apologize if I formulated it incomprehensibly.
Answer the question
In order to leave comments, you need to log in
The question is not entirely clear, but I guess that the correct typing of this hook is needed, the IDE looks at it to form the autocomplete list.
You can do something like this: https://www.typescriptlang.org/play?#code/C4TwDgpg...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question