How do I coerce this function to accept multiple types then conditionally change the output?
Using traditional overloading approach doesn't seem to work as expected. Union types on parameters does not resolve the output type properly:
Error:
4 Replies
hmm if block resolves to T & number but return type doesnt accept the return
oh you cast it
Solution
i was looking around a bit and found this pattern with overloads
seems like a better solution for my use case
though i should be more familiar with extends uses, will definitely be useful
thanks!