@@ -43,14 +43,14 @@ export class LuaPrinter {
4343 private options : CompilerOptions ;
4444 private currentIndent : string ;
4545
46- private sourceFile : string ;
46+ private sourceFile = "" ;
4747
4848 public constructor ( options : CompilerOptions ) {
4949 this . options = options ;
5050 this . currentIndent = "" ;
5151 }
5252
53- public print ( block : tstl . Block , luaLibFeatures ?: Set < LuaLibFeature > , sourceFile ?: string ) : [ string , string ] {
53+ public print ( block : tstl . Block , luaLibFeatures ?: Set < LuaLibFeature > , sourceFile = "" ) : [ string , string ] {
5454 // Add traceback lualib if sourcemap traceback option is enabled
5555 if ( this . options . sourceMapTraceback ) {
5656 if ( luaLibFeatures === undefined ) {
@@ -83,7 +83,7 @@ export class LuaPrinter {
8383 const map = sourceMap . toString ( ) ;
8484 const base64Map = Buffer . from ( map ) . toString ( 'base64' ) ;
8585
86- return `// # sourceMappingURL=data:application/json;base64,${ base64Map } \n` ;
86+ return `-- # sourceMappingURL=data:application/json;base64,${ base64Map } \n` ;
8787 }
8888
8989 private printStackTraceOverride ( rootNode : SourceNode ) : string {
@@ -113,7 +113,7 @@ export class LuaPrinter {
113113 private printImplementation (
114114 block : tstl . Block ,
115115 luaLibFeatures ?: Set < LuaLibFeature > ,
116- sourceFile ?: string ) : SourceNode {
116+ sourceFile = "" ) : SourceNode {
117117
118118 let header = "" ;
119119
@@ -165,13 +165,15 @@ export class LuaPrinter {
165165 private createSourceNode ( node : tstl . Node , chunks : SourceChunk | SourceChunk [ ] ) : SourceNode {
166166 const originalPos = tstl . getOriginalPos ( node ) ;
167167
168- return originalPos !== undefined
168+ return originalPos !== undefined && originalPos . line !== undefined && originalPos . column !== undefined
169169 ? new SourceNode ( originalPos . line + 1 , originalPos . column , this . sourceFile , chunks )
170- : new SourceNode ( undefined , undefined , this . sourceFile , chunks ) ;
170+ // tslint:disable-next-line:no-null-keyword
171+ : new SourceNode ( null , null , this . sourceFile , chunks ) ;
171172 }
172173
173174 private concatNodes ( ...chunks : SourceChunk [ ] ) : SourceNode {
174- return new SourceNode ( undefined , undefined , this . sourceFile , chunks ) ;
175+ // tslint:disable-next-line:no-null-keyword
176+ return new SourceNode ( null , null , this . sourceFile , chunks ) ;
175177 }
176178
177179 private printBlock ( block : tstl . Block ) : SourceNode {
@@ -619,19 +621,26 @@ export class LuaPrinter {
619621
620622 private printCallExpression ( expression : tstl . CallExpression ) : SourceNode {
621623 const chunks = [ ] ;
622- const parameterChunks = this . joinChunks ( ", " , expression . params . map ( e => this . printExpression ( e ) ) ) ;
623624
624- chunks . push ( this . printExpression ( expression . expression ) , "(" , ...parameterChunks , ")" ) ;
625+ const parameterChunks = expression . params !== undefined
626+ ? expression . params . map ( e => this . printExpression ( e ) )
627+ : [ ] ;
628+
629+ chunks . push ( this . printExpression ( expression . expression ) , "(" , ...this . joinChunks ( ", " , parameterChunks ) , ")" ) ;
625630
626631 return this . concatNodes ( ...chunks ) ;
627632 }
628633
629634 private printMethodCallExpression ( expression : tstl . MethodCallExpression ) : SourceNode {
630635 const prefix = this . printExpression ( expression . prefixExpression ) ;
631- const parameterChunks = this . joinChunks ( ", " , expression . params . map ( e => this . printExpression ( e ) ) ) ;
636+
637+ const parameterChunks = expression . params !== undefined
638+ ? expression . params . map ( e => this . printExpression ( e ) )
639+ : [ ] ;
640+
632641 const name = this . printIdentifier ( expression . name ) ;
633642
634- return this . concatNodes ( prefix , ":" , name , "(" , ...parameterChunks , ")" ) ;
643+ return this . concatNodes ( prefix , ":" , name , "(" , ...this . joinChunks ( ", " , parameterChunks ) , ")" ) ;
635644 }
636645
637646 private printIdentifier ( expression : tstl . Identifier ) : SourceNode {
0 commit comments