Answers for "convert an array of strings into union of literal types"

0

convert an array of strings into union of literal types

// Only works for literal arrays

const someArr = ["a", "b", "c"] as const

type UnionOfSomeArrValue = typeof someArr[number] // => "a" | "b" | "c"
Posted by: Guest on July-13-2021

Code answers related to "convert an array of strings into union of literal types"

Browse Popular Code Answers by Language