I'm just wondering if it is possible to type an array with a unifying type so that one array can contain both apples and oranges, but nothing more.
Sort of
var arr : (Apple|Orange)[] = [];
arr.push(apple);
arr.push(orange);
arr.push(1);
arr.push("abc");
Needless to say, the above example does not work, so it may not be possible, or am I missing something?
source
share