Having a background in JS, I am currently exploring TS.
My goal is to create an object with a single field, which is an array of strings, while ensuring strong typing.
let container = {
items: ['Item 1']
}
container.items[0] = 3; // This is incorrect
Although providing an initial value works, what if I want to leave items
empty? Here's an example:
let container = {
items<String>: []
}
container.items.push(3) // This is wrong
container.items.push('abc') // This is correct