Types do not exist in emitted code - you can't go from a type to an array.

But you could go the other way around, in some situations. If the array is not dynamic (or its values can be completely determined by the type-checker at the time it's initialized), you can declare the array as const (so that the array's type is ["aaa", "bbb", "ccc"] rather than string[]), and then create a type from it by mapping its values from arr[number]:

const arr = ["aaa", "bbb", "ccc"] as const;
type myCustomType = typeof arr[number];

Here's an example on the playground.

Answer from CertainPerformance on Stack Overflow
🌐
W3Schools
w3schools.com › typescript › typescript_arrays.php
TypeScript Arrays
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT SWIFT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS · TS HOME TS Introduction TS Get Started TS Simple Types TS Explicit & Inference TS Special Types TS Arrays ...
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_array_tostring.htm
TypeScript - Array toString()
Python TechnologiesDatabasesComputer ... JavaScript ... TypeScript - null vs. undefined ... toString() method returns a string representing the source code of the specified array ......
Discussions

How to convert typescript types of strings to array of strings?
I've this type: type myCustomType = "aaa" | "bbb" | "ccc"; I need to convert it to an array like this: ["aaa", "bbb", "ccc"] How can I do this in typescript? More on stackoverflow.com
🌐 stackoverflow.com
TypeScript array to string literal type - Stack Overflow
I currently have both an array of strings and a string literal union type containing the same strings: const furniture = ['chair', 'table', 'lamp']; type Furniture = 'chair' | 'table' | 'lamp'; I ... More on stackoverflow.com
🌐 stackoverflow.com
How to define an array of strings in TypeScript interface? - Stack Overflow
TypeScript supports arrays, similar to JavaScript. There are two ways to declare an array: Using square brackets. This method is similar to how you would declare arrays in JavaScript. let fruits: string[] = ['Apple', 'Orange', 'Banana']; More on stackoverflow.com
🌐 stackoverflow.com
What is {[key: string]: string} and how do I turn it into an array?
It's an object with both keys and values being of type string. Object.values(thisThing) should give you an array of values. edit: This type is an equivalent of Record More on reddit.com
🌐 r/typescript
10
13
January 24, 2023
🌐
Tutorial Teacher
tutorialsteacher.com › typescript › typescript-array
TypeScript Arrays
TypeScript supports arrays, similar to JavaScript. There are two ways to declare an array: 1. Using square brackets. This method is similar to how you would declare arrays in JavaScript. let fruits: string[] = ['Apple', 'Orange', 'Banana'];
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_arrays.htm
TypeScript - Arrays
To declare an initialize an array in Typescript use the following syntax −
Top answer
1 of 4
383

TypeScript 3.4+

TypeScript version 3.4 has introduced so-called **const contexts**, which is a way to declare a tuple type as immutable and get the narrow literal type directly (without the need to call a function like shown below in the 3.0 solution).

With this new syntax, we get this nice concise solution:

const furniture = ['chair', 'table', 'lamp'] as const;
type Furniture = typeof furniture[number];

More about the new const contexts is found in this PR as well as in the release notes.

TypeScript 3.0+

With the use of generic rest parameters, there is a way to correctly infer string[] as a literal tuple type and then get the union type of the literals.

It goes like this:

const tuple = <T extends string[]>(...args: T) => args;
const furniture = tuple('chair', 'table', 'lamp');
type Furniture = typeof furniture[number];

More about generic rest parameters

2 of 4
22

This answer is out of date; see @ggradnig's answer.

The best available workaround:

const furnitureObj = { chair: 1, table: 1, lamp: 1 };
type Furniture = keyof typeof furnitureObj;
const furniture = Object.keys(furnitureObj) as Furniture[];

Ideally we could do this:

const furniture = ['chair', 'table', 'lamp'];
type Furniture = typeof furniture[number];

Unfortunately, today furniture is inferred as string[], which means Furniture is now also a string.

We can enforce the typing as a literal with a manual annotation, but it brings back the duplication:

const furniture = ["chair", "table", "lamp"] as ["chair", "table", "lamp"];
type Furniture = typeof furniture[number];

TypeScript issue #10195 tracks the ability to hint to TypeScript that the list should be inferred as a static tuple and not string[], so maybe in the future this will be possible.

🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-create-array-of-string-in-typescript
How to Create Array of String in TypeScript ? - GeeksforGeeks
August 5, 2025 - This approach is useful when we want to initialize an array with repeated string values. ... Example: The below code add elements to the array using the TypeScript fill() method.
Find elsewhere
🌐
Python Guides
pythonguides.com › convert-a-string-to-a-byte-array-in-typescript
How To Convert A String To A Byte Array In TypeScript?
May 21, 2025 - In this example, we create an instance of the TextEncoder class and use its encode method to convert the string “John Doe” to a byte array. The result byteArray is of type Uint8Array, which represents an array of unsigned 8-bit integers. Check out: Convert an Object to an Array in TypeScript
🌐
GeeksforGeeks
geeksforgeeks.org › typescript-array-tostring-method
TypeScript Array toString() Method - GeeksforGeeks
July 12, 2024 - In this article, we will try to understand how we to extend an interface from a class in TypeScript with the help of certain coding examples. Let us first quickly understand how we can create a class as well as an interface in TypeScript using the following mentioned syntaxes: Syntax:Â This is the s ... TypeScript object is a collection of key-value pairs, where keys are strings and values can be any data type. Objects in TypeScript can store various types, including primitives, arrays, and functions, providing a structured way to organize and manipulate data.Creating Objects in TypescriptNow, let
Top answer
1 of 3
18

Building on top of jcal's answer and reiterating: "You can't convert types in TypeScript to values at runtime. But you can do the reverse: create a runtime object and have TypeScript infer its type." There is a great blog post by @steve-holgado to use const assertions for this purpose: https://steveholgado.com/typescript-types-from-arrays/

With typescript's const assertions (TypeScript 3.4+) you can do:

const animals = ['cat', 'dog', 'mouse'] as const
type Animal = typeof animals[number]

// type Animal = 'cat' | 'dog' | 'mouse'

So the question's code would look like:

const imageVerticalSpacing = ['ignoreBottom', 'ignoreTop', 'ignoreBoth', 'Default'];
type ImageVerticalSpacing = typeof imageVerticalSpacing[number];
2 of 3
6

You can't convert types in TypeScript to values at runtime. But you can do the reverse: create a runtime object and have TypeScript infer its type.

The ideal runtime object for this purpose would be a tuple. Unfortunately, TypeScript doesn't infer tuples that well by itself. I use a helper function called tuple() which returns tuple types.

UPDATE: 2018-12, since TypeScript 3.0 the tuple() function can be written like this:

type Narrowable = string | number | boolean | symbol | 
  object | {} | void | null | undefined;
const tuple = <T extends Narrowable[]>(...args: T)=>args;

Using the above helper function, you can do this:

const imageVerticalSpacing = tuple('ignoreBottom','ignoreTop','ignoreBoth','Default');

type ImageVerticalSpacing = (typeof imageVerticalSpacing)[number];

The imageVerticalSpacing object is an array of strings you can use for your dropdown, of type ['ignoreBottom','ignoreTop','ignoreBoth','Default']. And the type ImageVerticalSpacing is the same 'ignoreBottom' | 'ignoreTop' | 'ignoreBoth' | 'Default' as you declared.

(See it in action on The Playground)

Hope that helps. Good luck!

🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_string_split.htm
TypeScript - String split()
This method splits a String object into an array of strings by separating the string into substrings. The split method returns the new array. Also, when the string is empty, split returns an array containing one empty string, rather than an empty
🌐
TkDodo
tkdodo.eu › blog › array-types-in-type-script
Array Types in TypeScript
August 19, 2023 - What we want is: (string | number)[], with parentheses, to make our code work. The generic version doesn’t have this problem because it separates Array from its content with the angle brackets anyway.
🌐
W3Schools
w3schools.com › jsref › jsref_tostring_array.asp
JavaScript Array toString() Method
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS ... Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_array_join.htm
TypeScript - Array join()
Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories ... TypeScript vs. JavaScript ... TypeScript - null vs. undefined ... separator − Specifies a string to separate each element of the array...
🌐
Mimo
mimo.org › glossary › typescript › array
Mimo: The coding platform you need to learn Web Development, Python, and more.
A TypeScript array is a collection of elements of a specific type. You use it to store lists of data—strings, numbers, objects, or even other arrays—with all the safety and support that TypeScript's static typing provides.
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › everyday-types.html
TypeScript: Documentation - Everyday Types
For example, TypeScript knows that only a string value will have a typeof value "string": ... Notice that in the else branch, we don’t need to do anything special - if x wasn’t a string[], then it must have been a string. Sometimes you’ll have a union where all the members have something in common. For example, both arrays ...