I am updating an open-source typescript module that allows you to work with all of the common vendors. I need to have an array vendors
that has all of the vendors as the Vendor
type. Is there a way to have the same effect from the code, but not have to repeat all of the vendors twice?
type Vendor =
| "ah"
| "apple"
| "atsc"
| "epub"
| "hp"
| "khtml"
| "moz"
| "ms"
| "o"
| "rim"
| "ro"
| "tc"
| "wap"
| "webkit"
| "xv";
const vendors: Vendor[] = [
"ah",
"apple",
"atsc",
"epub",
"hp",
"khtml",
"moz",
"ms",
"o",
"rim",
"ro",
"tc",
"wap",
"webkit",
"xv",
];
Please don't tell me to just add the string[]
type to the vendors
array because I need to use the Vendor
type in other places within the code.
Thanks for your help and sorry that I am a typescript noob ;)