Why does type inference via generic function parameter to return type not work
I had a specific function to map from an array to a single item. Now that I want to map it based on the discriminator so I am trying to implement a more generic function.
I have a function with input parameter of a union type which have a discriminator.
Another parameter is the discriminator of the union[‘type’]. Why cant typescript infer the return type based on that parameter? I struggle to find an explanation.
Infer more specific type from dictionary? How to help TypeScript to infer the type?
I got this super code:
Why does typescript can’t infer correctly my types ? And can I help typescript to infer the type?
I got this super code.