This deeply annoys me: let f = (x: string | boolean) => x; let y: string = f('hey'); // Error: "not assignable to type 'string'"
-
-
That has the same problem as the other three solutions people gave me for my overly simplified tweet-sized example: ...
-
What about when the input and output types are not the same?
-
Never mind that this is far beyond the verbosity threshold when there are a non-trivial number of overloads.
-
The specific problem you're trying to solve is "output is the same as some input"?
-
https://twitter.com/BrandonBloom/status/925505166974918656 … Let me see if I can find a reasonable toy example.
-
Ah, is this what you meant by "mapping interface"? This is a clever trick.
-
Yah I was going to recommend the same thing with Flow https://flow.org/try/#0C4TwDgpgBAShwFcBOA7AsgQzFAvFA3gFBRQBEAzsEgJYoDmpAXFAEYD2bANhBigDTEy7LjxRMolGvQEBfANyFC3YFABmuKAB4AKs0m06APgAUAD2baAlMwAkAUW4BbCCmDbwETXESpMYPlDahrjB+DKKylAAbhicGqrGAOTC3LyJlgqExjGcelQGlkA … (assumed TS had something similar)...
- 6 more replies
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.