@@ -6,6 +6,7 @@ import { LuaLibFeature, transformLuaLibFunction } from "../utils/lualib";
66import { PropertyCallExpression , transformArguments , transformCallAndArguments } from "../visitors/call" ;
77import { isStringType , isNumberType , findFirstNonOuterParent } from "../utils/typescript" ;
88import { moveToPrecedingTemp } from "../visitors/expression-list" ;
9+ import { isUnpackCall } from "../utils/lua-ast" ;
910
1011export function transformArrayConstructorCall (
1112 context : TransformationContext ,
@@ -76,8 +77,20 @@ export function transformArrayPrototypeCall(
7677 case "entries" :
7778 return transformLuaLibFunction ( context , LuaLibFeature . ArrayEntries , node , caller ) ;
7879 case "push" :
79- if ( node . arguments . length === 1 && ! ts . isSpreadElement ( node . arguments [ 0 ] ) ) {
80- return transformSingleElementArrayPush ( context , node , caller , params [ 0 ] ) ;
80+ if ( node . arguments . length === 1 ) {
81+ const param = params [ 0 ] ;
82+ if ( isUnpackCall ( param ) ) {
83+ return transformLuaLibFunction (
84+ context ,
85+ LuaLibFeature . ArrayPushArray ,
86+ node ,
87+ caller ,
88+ ( param as lua . CallExpression ) . params [ 0 ]
89+ ) ;
90+ }
91+ if ( ! lua . isDotsLiteral ( param ) ) {
92+ return transformSingleElementArrayPush ( context , node , caller , param ) ;
93+ }
8194 }
8295
8396 return transformLuaLibFunction ( context , LuaLibFeature . ArrayPush , node , caller , ...params ) ;
0 commit comments