0

I have a type union defined like:

type UnionType = "PK_1" | "PK_2" | "PK_3" | "PK_4";

I'd like to convert such type union to a type array like:

type ArrayType = Convert<UnionType>; // Should be ["PK_1", "PK_2", "PK_3", "PK_4"];

How can I make such Convert method?

jayatubi
  • 1,972
  • 1
  • 21
  • 51
  • *"I'd like to convert such type union to an array like"* To an *array*, or to an *array **type***? – T.J. Crowder Aug 27 '21 at 07:49
  • 2
    Does this answer your question? [How to transform union type to tuple type](https://stackoverflow.com/questions/55127004/how-to-transform-union-type-to-tuple-type) – Ryan Le Aug 27 '21 at 07:50
  • 1
    @T.J.Crowder Yes. I meant type array. – jayatubi Aug 27 '21 at 07:50
  • @jayatubi - Just for what it's worth, it's "array type" (tuple type), not a "type array". "Array" is the adjective, "type" is the noun. Just to avoid confusing people. :-) – T.J. Crowder Aug 27 '21 at 07:52

0 Answers0