In TypeScript, what is the difference between Array
and any[]
? Does Array refer to dynamically sized arrays (during compile-time, of course) and any[]
refer to statically sized arrays passed as arguments and type-inferred by the compiler? Because currently when I have functions such as:
mergeArrays(arr1 : Array, arr2 : Array);
When you call this function with static data, TypeScript uses a typed array (type[]
).
mergeArrays([true, false], [1, 2]);
// bool[] number[]
So are there any compile-time differences between the 2? When do I use any[]
and when do I use Array
? Sometimes defining vars with Array
..
var info:Array;
..show errors like "Cannot convert any[][] to Array" when setting as follows:
info = [[], []];
See Question&Answers more detail:os