File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ export abstract class LuaTranspiler {
294294 case ts . SyntaxKind . TryStatement :
295295 return this . transpileTry ( node as ts . TryStatement ) ;
296296 case ts . SyntaxKind . ThrowStatement :
297- return this . transpileThrow ( node as ts . ThrowStatement ) ;
297+ return this . indent + this . transpileThrow ( node as ts . ThrowStatement ) + ";\n" ;
298298 case ts . SyntaxKind . ContinueStatement :
299299 return this . transpileContinue ( node as ts . ContinueStatement ) ;
300300 case ts . SyntaxKind . TypeAliasDeclaration :
@@ -683,8 +683,9 @@ export abstract class LuaTranspiler {
683683 }
684684
685685 public transpileThrow ( node : ts . ThrowStatement ) : string {
686- if ( ts . isStringLiteral ( node . expression ) ) {
687- return `error("${ node . expression . text } ")` ;
686+ const type = this . checker . getTypeAtLocation ( node . expression ) ;
687+ if ( tsHelper . isStringType ( type ) ) {
688+ return `error(${ this . transpileExpression ( node . expression ) } )` ;
688689 } else {
689690 throw TSTLErrors . InvalidThrowExpression ( node . expression ) ;
690691 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export class LuaErrorTests {
1212 `throw "Some Error"`
1313 ) ;
1414 // Assert
15- Expect ( lua ) . toBe ( `error("Some Error")` ) ;
15+ Expect ( lua ) . toBe ( `error("Some Error"); ` ) ;
1616 }
1717
1818 @Test ( "throwError" )
You can’t perform that action at this time.
0 commit comments