How to remove TypeScript warning: property 'length' does not exist on type '{}'
multidimensional-array, typescript
Solution
Option 1: upgrade to bleeding-edge compiler and get union types
Option 2: Add a type annotation to the variable declaration:
var myArr: any[] = ['one', [[19, 1], [13, 1], [86, 1], [12, 2]],
'two', [[83, 1], [72, 1], [16, 2]],
'three', [[4, 1]]];
function testArray(){
console.log(myArr[1].length);
}
Problem
In a TypeScript file, I have defined a 3D array: ``` var myArr = ['one', [[19, 1], [13, 1], [86, 1], [12, 2]], 'two', [[83, 1], [72, 1], [16, 2]], 'three', [[4, 1]]]; function testArray(){ console.log(myArr[1].length); } ``` I get a warning under the length property: Property 'length' does not exist on type '{}' Is there something I can do to remove this warning?