What about when the input and output types are not the same?
-
-
Heh, I'm actively trying to decide if I want to employ that solution or if I'd rather just use some casts. Leaning towards latter.
-
Especially since with the casts in there right now, my tests are passing! :-P
End of conversation
New conversation -
-
-
I'm kind of with Brandon on this. Your examples are great but I can't help but feel there exists a better way to express this idea (not TS)
-
TS is in a bind because it (wisely) chose to avoid changing JavaScript’s runtime semantics. In another setting, here’s how I’d handle this:
-
Have a first class notion of overloading and partial functions. The dispatch strategy should be part of the type.
-
Compare to Clojure: (defmulti transform :head) (defmethod transform :whatever [ast] ...) Can infer precise overload types from this!
-
Given extensible/open type definitions, this could even macroexpand to the crazy mapping types solution.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.