@@ -145,7 +145,7 @@ var LuaTranspiler = /** @class */ (function () {
145145 } ;
146146 LuaTranspiler . prototype . transpileImport = function ( node ) {
147147 var importFile = this . transpileExpression ( node . moduleSpecifier ) ;
148- if ( ! node . importClause ) {
148+ if ( ! node . importClause || ! node . importClause . namedBindings ) {
149149 throw new TranspileError ( "Default Imports are not supported, please use named imports instead!" , node ) ;
150150 }
151151 var imports = node . importClause . namedBindings ;
@@ -542,16 +542,20 @@ var LuaTranspiler = /** @class */ (function () {
542542 var params_1 = this . transpileArguments ( node . arguments ) ;
543543 return this . transpileMathExpression ( node . expression . name ) + ( "(" + params_1 + ")" ) ;
544544 }
545+ if ( ts . isIdentifier ( node . expression ) && node . expression . escapedText == "String" ) {
546+ var params_2 = this . transpileArguments ( node . arguments ) ;
547+ return this . transpileStringExpression ( node . expression . name ) + ( "(" + params_2 + ")" ) ;
548+ }
545549 // Include context parameter if present
546550 var callPath_1 = ( expType && expType . symbol ) ? expType . symbol . name + "." + node . expression . name . escapedText : this . transpileExpression ( node . expression ) ;
547- var params_2 = this . transpileArguments ( node . arguments , node . expression . expression ) ;
548- return callPath_1 + "(" + params_2 + ")" ;
551+ var params_3 = this . transpileArguments ( node . arguments , node . expression . expression ) ;
552+ return callPath_1 + "(" + params_3 + ")" ;
549553 }
550554 // Handle super calls properly
551555 if ( node . expression . kind == ts . SyntaxKind . SuperKeyword ) {
552556 var callPath_2 = this . transpileExpression ( node . expression ) ;
553- var params_3 = this . transpileArguments ( node . arguments , ts . createNode ( ts . SyntaxKind . ThisKeyword ) ) ;
554- return "self.__base.constructor(" + params_3 + ")" ;
557+ var params_4 = this . transpileArguments ( node . arguments , ts . createNode ( ts . SyntaxKind . ThisKeyword ) ) ;
558+ return "self.__base.constructor(" + params_4 + ")" ;
555559 }
556560 var callPath = this . transpileExpression ( node . expression ) ;
557561 var params = this . transpileArguments ( node . arguments ) ;
@@ -584,6 +588,21 @@ var LuaTranspiler = /** @class */ (function () {
584588 throw new TranspileError ( "Unsupported string function: " + expression . name . escapedText , node ) ;
585589 }
586590 } ;
591+ // Transpile a String._ property
592+ LuaTranspiler . prototype . transpileStringExpression = function ( identifier ) {
593+ var translation = {
594+ fromCharCode : "string.char" ,
595+ fromCodePoint : "utf8.char"
596+ } ;
597+ // TODO at check if compiler options is LUA 5.3
598+ // should throw an exception if codepoint is used sub 5.3
599+ if ( translation [ identifier . escapedText ] ) {
600+ return "" + translation [ identifier . escapedText ] ;
601+ }
602+ else {
603+ throw new TranspileError ( "Unsupported string property " + identifier . escapedText + "." , identifier ) ;
604+ }
605+ } ;
587606 LuaTranspiler . prototype . transpileArrayCallExpression = function ( node ) {
588607 var expression = node . expression ;
589608 var params = this . transpileArguments ( node . arguments ) ;
0 commit comments