When you don't give a type to the Array, the compiler assumes the type as 'any[]', hence there is no issue for TS and it thinks undefined belongs to any[]