How do I concat two types array in one array using concat. If I initialize it with two data types it works fine but when I concat it. Typescript throws an error that both types are incompatible.
const foo: string[] = ['hello', 'world'];
const bar: number[] = [1, 2];
const both: (string | number)[] = foo.concat(bar); // gets an error on bar
const other: (string | number)[] = ['hello', 'world', 2, 3]; // this works
tuple. Type of each element of thetupleshould be typed upfront.const tuple:[string,number]=['str', 42]. Furthermore V8 works better with homogeneous arrays