@@ -331,6 +331,8 @@ export class LuaTranspiler {
331331 case ts . SyntaxKind . StringLiteral :
332332 const text = ( < ts . StringLiteral > node ) . text ;
333333 return `"${ text } "` ;
334+ case ts . SyntaxKind . TemplateExpression :
335+ return this . transpileTemplateExpression ( < ts . TemplateExpression > node ) ;
334336 case ts . SyntaxKind . NumericLiteral :
335337 return ( < ts . NumericLiteral > node ) . text ;
336338 case ts . SyntaxKind . TrueKeyword :
@@ -361,6 +363,9 @@ export class LuaTranspiler {
361363 case ts . SyntaxKind . TypeAssertionExpression :
362364 // Simply ignore the type assertion
363365 return this . transpileExpression ( ( < ts . TypeAssertion > node ) . expression ) ;
366+ case ts . SyntaxKind . AsExpression :
367+ // Also ignore as casts
368+ return this . transpileExpression ( ( < ts . AsExpression > node ) . expression ) ;
364369 default :
365370 throw new TranspileError ( "Unsupported expression kind: " + tsEx . enumName ( node . kind , ts . SyntaxKind ) , node ) ;
366371 }
@@ -392,6 +397,11 @@ export class LuaTranspiler {
392397 case ts . SyntaxKind . BarToken :
393398 result = `bit.bor(${ lhs } ,${ rhs } )` ;
394399 break ;
400+ case ts . SyntaxKind . PlusToken :
401+ // Replace string + with ..
402+ const typeLeft = this . checker . getTypeAtLocation ( node . left ) ;
403+ if ( typeLeft . flags & ts . TypeFlags . String || ts . isStringLiteral ( node . left ) )
404+ return lhs + ".." + rhs ;
395405 default :
396406 result = lhs + this . transpileOperator ( node . operatorToken ) + rhs ;
397407 }
@@ -404,6 +414,19 @@ export class LuaTranspiler {
404414 }
405415 }
406416
417+ transpileTemplateExpression ( node : ts . TemplateExpression ) {
418+ let parts = [ `"${ node . head . text } "` ] ;
419+ node . templateSpans . forEach ( span => {
420+ const expr = this . transpileExpression ( span . expression , true ) ;
421+ if ( ts . isTemplateTail ( span . literal ) ) {
422+ parts . push ( expr + `.."${ span . literal . text } "` ) ;
423+ } else {
424+ parts . push ( expr + `.."${ span . literal . text } "` ) ;
425+ }
426+ } ) ;
427+ return parts . join ( ".." ) ;
428+ }
429+
407430 transpileConditionalExpression ( node : ts . ConditionalExpression , brackets ?: boolean ) : string {
408431 let condition = this . transpileExpression ( node . condition ) ;
409432 let val1 = this . transpileExpression ( node . whenTrue ) ;
0 commit comments