Consider this scenario with an array:
const testData = [
{ properties: { number: 1, name: 'haha' } , second: 'this type'},
['one', 'two', 'three'],
];
The goal is to access the value of 'second', which is 'this type', in this manner:
const wantToGet = testData[0].second;
However, TypeScript throws an error stating:
Property 'second' does not exist on type 'string[] | { properties: { number: number; name: string; }; second: string; }'.
Property 'second' does not exist on type 'string[]'
It's worth noting that testData[0] always represents an object, not an array. Why is that?