File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1151,14 +1151,33 @@ export class LuaTranspiler {
11511151
11521152 // Build parameter string
11531153 const paramNames : string [ ] = [ ] ;
1154- parameters . forEach ( ( param ) => {
1155- paramNames . push ( ( param . name as ts . Identifier ) . escapedText as string ) ;
1156- } ) ;
1154+
1155+ let spreadIdentifier = "" ;
1156+
1157+ // Only push parameter name to paramName array if it isn't a spread parameter
1158+ for ( const param of parameters ) {
1159+ const paramName = ( param . name as ts . Identifier ) . escapedText as string ;
1160+
1161+ // This parameter is a spread parameter (...param)
1162+ if ( ! param . dotDotDotToken ) {
1163+ paramNames . push ( paramName ) ;
1164+ } else {
1165+ spreadIdentifier = paramName ;
1166+ // Push the spread operator into the paramNames array
1167+ paramNames . push ( "..." ) ;
1168+ }
1169+ }
11571170
11581171 // Build function header
11591172 result += this . indent + this . accessPrefix ( node ) + `function ${ methodName } (${ paramNames . join ( "," ) } )\n` ;
11601173
11611174 this . pushIndent ( ) ;
1175+
1176+ // Push spread operator here
1177+ if ( spreadIdentifier !== "" ) {
1178+ result += ` local ${ spreadIdentifier } = { ... }\n` ;
1179+ }
1180+
11621181 result += this . transpileBlock ( body ) ;
11631182 this . popIndent ( ) ;
11641183
Original file line number Diff line number Diff line change 1+ function varargsFunction (a ,...)
2+ local b = { ... }
3+ end
Original file line number Diff line number Diff line change 1+ function varargsFunction ( a : string , ...b : string [ ] ) : void { }
You can’t perform that action at this time.
0 commit comments