@@ -1175,7 +1175,7 @@ export class LuaTranspiler {
11751175
11761176 // Push spread operator here
11771177 if ( spreadIdentifier !== "" ) {
1178- result += ` local ${ spreadIdentifier } = { ... }\n`;
1178+ result += this . indent + ` local ${ spreadIdentifier } = { ... }\n`;
11791179 }
11801180
11811181 result += this . transpileBlock ( body ) ;
@@ -1198,17 +1198,35 @@ export class LuaTranspiler {
11981198
11991199 // Build parameter string
12001200 const paramNames : string [ ] = [ "self" ] ;
1201- parameters . forEach ( ( param ) => {
1202- paramNames . push ( ( param . name as ts . Identifier ) . escapedText as string ) ;
1203- } ) ;
12041201
1202+ let spreadIdentifier = "" ;
1203+
1204+ // Only push parameter name to paramName array if it isn't a spread parameter
1205+ for ( const param of parameters ) {
1206+ const paramName = ( param . name as ts . Identifier ) . escapedText as string ;
1207+
1208+ // This parameter is a spread parameter (...param)
1209+ if ( ! param . dotDotDotToken ) {
1210+ paramNames . push ( paramName ) ;
1211+ } else {
1212+ spreadIdentifier = paramName ;
1213+ // Push the spread operator into the paramNames array
1214+ paramNames . push ( "..." ) ;
1215+ }
1216+ }
12051217 // Parameters with default values
12061218 const defaultValueParams = node . parameters . filter ( ( declaration ) => declaration . initializer !== undefined ) ;
12071219
12081220 // Build function header
12091221 result += this . indent + `function ${ callPath } ${ methodName } (${ paramNames . join ( "," ) } )\n` ;
12101222
12111223 this . pushIndent ( ) ;
1224+
1225+ // Push spread operator here
1226+ if ( spreadIdentifier !== "" ) {
1227+ result += this . indent + `local ${ spreadIdentifier } = { ... }\n` ;
1228+ }
1229+
12121230 result += this . transpileParameterDefaultValues ( defaultValueParams ) ;
12131231 result += this . transpileBlock ( body ) ;
12141232 this . popIndent ( ) ;
0 commit comments