TypeScriptToLua plugin that transforms exports into globals
npm install @ts-defold/tstl-userdata-sugarunpack function only supports unpacking tables, even if the required metamethods of __index and __len are present to treat them like an array.To support this feature we detect a ... of an Array & LuaUserdata type and implicitly inject a call to map(x => x). This then returns a table from the userdata and passes it to unpack. There may exist more efficient methods of unpacking your array data directly from the userdata type, and you may want to avoid this syntax sugar if moving large amounts of data.
``ts
declare type UserDataArray
};
declare function makeUserData(): UserDataArray
const userData: UserDataArray
console.log([...userData]);
``