Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ export abstract class LuaTranspiler {
return "";
case ts.SyntaxKind.SpreadElement:
return this.transpileSpreadElement(node as ts.SpreadElement);
case ts.SyntaxKind.NonNullExpression:
return this.transpileExpression((node as ts.NonNullExpression).expression);
case ts.SyntaxKind.Block:
this.pushIndent();
const ret = "do \n" + this.transpileBlock(node as ts.Block) + "end\n";
Expand Down
8 changes: 8 additions & 0 deletions test/unit/expressions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ export class ExpressionTests {
const result = util.transpileAndExecute(`let a = 4; {let a = 42; } return a;`);
Expect(result).toBe(4);
}

@Test("Non-null expression")
public nonNullExpression(): void {
const result = util.transpileAndExecute(`function abc(): number | undefined { return 3; }
const a: number = abc()!;
return a;`);
Expect(result).toBe(3);
}
// ====================================
// Test expected errors
// ====================================
Expand Down