0

I have a type that looks like this:

type StrOr = 'A'|'B'|'C'

Now, I need a type SplitStr that makes the SplitStr<StrOr> of type 'A|B|C'

How do I do that?

hyisYoo
  • 99
  • 2
  • Unions are unordered; there is absolutely no difference between the type `"A"|"B"|"C"` and the type `"C"|"A"|"B"` and it's a [very bad idea](https://stackoverflow.com/a/55128956/2887218) to try to distinguish those. That means your `SplitStr` can't really do what you're asking safely. You can do something that gives you a union of all possible joinings as shown [here](//tsplay.dev/WokA8W) shows, but that could get huge very quickly. It's *far* easier and safer to *start* with `"A|B|C"` and *produce* `"A" | "B" | "C"` from that, as shown [here](//tsplay.dev/mqe3Ym). What's the use case? – jcalz Dec 06 '22 at 18:10

0 Answers0