Use any member of a string union in a template literal at most once

Viewed 29

I have a union of 3 possible strings:

type AllowedWords = "one" | "two" | "three";

I want to create a template literal type that allows any of those 3 words in any order, but each member should only be included up to once. For example, this should be an exhaustive list of all possible matches:

  • one
  • two
  • three
  • onetwo
  • onethree
  • twoone
  • twothree
  • threeone
  • threetwo
  • onetwothree
  • onethreetwo
  • twoonethree
  • twothreeone
  • threeonetwo
  • threetwoone

How can I define a type that represents that?

0 Answers
Related