Sometimes, we want to create a strongly typed array of arrays in TypeScript.
In this article, we’ll look at how to create a strongly typed array of arrays in TypeScript.
How to create a strongly typed array of arrays in TypeScript?
To create a strongly typed array of arrays in TypeScript, we can nest the Array type.
For instance, we write
const x: Array<Array<Foo>> = [];
to declare variable x with the nested array entries having the Foo type with Array<Array<Foo>>.
Conclusion
To create a strongly typed array of arrays in TypeScript, we can nest the Array type.