@@ -23,8 +23,7 @@ const escapeStringMap: Record<string, string> = {
2323 "\0" : "\\0" ,
2424} ;
2525
26- export const escapeString = ( value : string ) =>
27- `"${ value . replace ( escapeStringRegExp , char => escapeStringMap [ char ] || char ) } "` ;
26+ export const escapeString = ( value : string ) => `"${ value . replace ( escapeStringRegExp , char => escapeStringMap [ char ] ) } "` ;
2827
2928/**
3029 * Checks that a name is valid for use in lua function declaration syntax:
@@ -198,7 +197,7 @@ export class LuaPrinter {
198197 header += `--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\n` ;
199198 }
200199
201- const luaLibImport = this . options . luaLibImport || LuaLibImportKind . Require ;
200+ const luaLibImport = this . options . luaLibImport ?? LuaLibImportKind . Require ;
202201 if (
203202 luaLibImport === LuaLibImportKind . Always ||
204203 ( luaLibImport === LuaLibImportKind . Require && luaLibFeatures . size > 0 )
@@ -341,11 +340,21 @@ export class LuaPrinter {
341340 // Print all local functions as `local function foo()` instead of `local foo = function` to allow recursion
342341 chunks . push ( this . printFunctionDefinition ( statement ) ) ;
343342 } else {
344- chunks . push ( ...this . joinChunks ( ", " , statement . left . map ( e => this . printExpression ( e ) ) ) ) ;
343+ chunks . push (
344+ ...this . joinChunks (
345+ ", " ,
346+ statement . left . map ( e => this . printExpression ( e ) )
347+ )
348+ ) ;
345349
346350 if ( statement . right ) {
347351 chunks . push ( " = " ) ;
348- chunks . push ( ...this . joinChunks ( ", " , statement . right . map ( e => this . printExpression ( e ) ) ) ) ;
352+ chunks . push (
353+ ...this . joinChunks (
354+ ", " ,
355+ statement . right . map ( e => this . printExpression ( e ) )
356+ )
357+ ) ;
349358 }
350359 }
351360
@@ -369,9 +378,19 @@ export class LuaPrinter {
369378 }
370379 }
371380
372- chunks . push ( ...this . joinChunks ( ", " , statement . left . map ( e => this . printExpression ( e ) ) ) ) ;
381+ chunks . push (
382+ ...this . joinChunks (
383+ ", " ,
384+ statement . left . map ( e => this . printExpression ( e ) )
385+ )
386+ ) ;
373387 chunks . push ( " = " ) ;
374- chunks . push ( ...this . joinChunks ( ", " , statement . right . map ( e => this . printExpression ( e ) ) ) ) ;
388+ chunks . push (
389+ ...this . joinChunks (
390+ ", " ,
391+ statement . right . map ( e => this . printExpression ( e ) )
392+ )
393+ ) ;
375394
376395 return this . createSourceNode ( statement , chunks ) ;
377396 }
@@ -458,8 +477,14 @@ export class LuaPrinter {
458477 }
459478
460479 public printForInStatement ( statement : lua . ForInStatement ) : SourceNode {
461- const names = this . joinChunks ( ", " , statement . names . map ( i => this . printIdentifier ( i ) ) ) ;
462- const expressions = this . joinChunks ( ", " , statement . expressions . map ( e => this . printExpression ( e ) ) ) ;
480+ const names = this . joinChunks (
481+ ", " ,
482+ statement . names . map ( i => this . printIdentifier ( i ) )
483+ ) ;
484+ const expressions = this . joinChunks (
485+ ", " ,
486+ statement . expressions . map ( e => this . printExpression ( e ) )
487+ ) ;
463488
464489 const chunks : SourceChunk [ ] = [ ] ;
465490
@@ -488,7 +513,12 @@ export class LuaPrinter {
488513
489514 const chunks : SourceChunk [ ] = [ ] ;
490515
491- chunks . push ( ...this . joinChunks ( ", " , statement . expressions . map ( e => this . printExpression ( e ) ) ) ) ;
516+ chunks . push (
517+ ...this . joinChunks (
518+ ", " ,
519+ statement . expressions . map ( e => this . printExpression ( e ) )
520+ )
521+ ) ;
492522
493523 return this . createSourceNode ( statement , [ this . indent ( ) , "return " , ...chunks ] ) ;
494524 }
@@ -588,7 +618,10 @@ export class LuaPrinter {
588618 chunks . push ( " " ) ;
589619 const returnNode : SourceChunk [ ] = [
590620 "return " ,
591- ...this . joinChunks ( ", " , returnStatement . expressions . map ( e => this . printExpression ( e ) ) ) ,
621+ ...this . joinChunks (
622+ ", " ,
623+ returnStatement . expressions . map ( e => this . printExpression ( e ) )
624+ ) ,
592625 ] ;
593626 chunks . push ( this . createSourceNode ( returnStatement , returnNode ) ) ;
594627 chunks . push ( this . createSourceNode ( expression , " end" ) ) ;
@@ -780,7 +813,12 @@ export class LuaPrinter {
780813 const chunks : SourceChunk [ ] = [ ] ;
781814
782815 if ( expressions . every ( isSimpleExpression ) ) {
783- chunks . push ( ...this . joinChunks ( ", " , expressions . map ( e => this . printExpression ( e ) ) ) ) ;
816+ chunks . push (
817+ ...this . joinChunks (
818+ ", " ,
819+ expressions . map ( e => this . printExpression ( e ) )
820+ )
821+ ) ;
784822 } else {
785823 chunks . push ( "\n" ) ;
786824 this . pushIndent ( ) ;
0 commit comments