File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -803,6 +803,8 @@ export abstract class LuaTranspiler {
803803 return "" ;
804804 case ts . SyntaxKind . SpreadElement :
805805 return this . transpileSpreadElement ( node as ts . SpreadElement ) ;
806+ case ts . SyntaxKind . NonNullExpression :
807+ return this . transpileExpression ( ( node as ts . NonNullExpression ) . expression ) ;
806808 case ts . SyntaxKind . Block :
807809 this . pushIndent ( ) ;
808810 const ret = "do \n" + this . transpileBlock ( node as ts . Block ) + "end\n" ;
Original file line number Diff line number Diff line change @@ -290,6 +290,14 @@ export class ExpressionTests {
290290 const result = util . transpileAndExecute ( `let a = 4; {let a = 42; } return a;` ) ;
291291 Expect ( result ) . toBe ( 4 ) ;
292292 }
293+
294+ @Test ( "Non-null expression" )
295+ public nonNullExpression ( ) : void {
296+ const result = util . transpileAndExecute ( `function abc(): number | undefined { return 3; }
297+ const a: number = abc()!;
298+ return a;` ) ;
299+ Expect ( result ) . toBe ( 3 ) ;
300+ }
293301 // ====================================
294302 // Test expected errors
295303 // ====================================
You can’t perform that action at this time.
0 commit comments