Categories
TypeScript Answers

How to define an array of strings in a TypeScript interface?

Spread the love

Sometimes, we want to define an array of strings in a TypeScript interface.

In this article, we’ll look at how to define an array of strings in a TypeScript interface.

How to define an array of strings in a TypeScript interface?

To define an array of strings in a TypeScript interface, we can set a property to a string variable.

For instance, we write

interface Addressable {
  address: string[];
}

to define the Addressable interface with the address property set to a string array with string[].

Conclusion

To define an array of strings in a TypeScript interface, we can set a property to a string variable.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *