The Datum interface is just too broad. It will represent basically any object (ie indexable by a string and the result of the indexing operation is any).
Given the object type is soo wide, both Datum and Datum[] and Datum[][] are assignable to an array type, and thus you don't get any error. Make the interface a bit more specific and you get an error. Ex:
interface Datum {
[k: string]: boolean | number | string;
}
type Data = Datum[]
const inner = (data: Data) => {
console.log(data)
};
const outer = (data: Data | Data[]) => {
inner(data) // error now
};
Or as @PatrickRoberts mentions in comments you can add a number index to the interface to make it explicitly incompatible with an array:
interface Datum {
[i: number]: never
[k: string]: any;
}
type Data = Datum[]
const inner = (data: Data) => {
console.log(data)
};
const outer = (data: Data | Data[]) => {
inner(data) // error
};
type Data = Datum[]