By Hemanta Sundaray on 2023-02-15
The simplest way to type annotate an array is by putting square brackets ([]) after the element type.
For example, suppose we have an array of strings:
let brands = ["Kia", "Toyota", "Honda"]
We can annotate it like this:
let brands: string[] = ["Kia", "Toyota", "Honda"]
An alternative method is to use the Array<type> syntax.
let brands: Array<string> = ["Kia", "Toyota", "Honda"]