The corresponding TypeScript types generated for this looks like this
Notice the types generated for the Motoko List types. They are nested types. So, when I get the result of any of those fields, they are nested as many layers as there are elements returned.
Looks like this:
This makes no sense intuitively. Why doesn’t a List return a plain JavaScript array instead of this nested mess?
Lists are functional in their construction so each object points to the next one in the list. User toArray(List<T) when returning your function and you will get a uniform array.
Maybe converting the List to an Array on the canister side might result in fewer cycles spent overall, if the list is small enough? For example, my guess is that it’s probably more computationally expensive to serialize a List to Candid than an Array. No idea, just a guess…