Answer the question
In order to leave comments, you need to log in
How to get type of one from object key and use for function argument in TS?
Hello, there is a generic function that accepts a function that returns a promise with a given data type. The problem is that this data type can have a different unique key, id or uuid, while in the case of id it is a number, and uuid is a string. How to make TS understand that if the id key is available, then the argument accepted in the fetcher function must be a number, and if uuid, then a string?
https://www.typescriptlang.org/play?#code/C4TwDgpg...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question