-
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathvoid.ts
More file actions
15 lines (13 loc) · 695 Bytes
/
void.ts
File metadata and controls
15 lines (13 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import * as ts from "typescript";
import * as lua from "../../LuaAST";
import { FunctionVisitor } from "../context";
import { wrapInStatement } from "./expression-statement";
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
export const transformVoidExpression: FunctionVisitor<ts.VoidExpression> = (node, context) => {
// If content is a literal it is safe to replace the entire expression with nil
if (!ts.isLiteralExpression(node.expression)) {
const statements = wrapInStatement(context.transformExpression(node.expression));
if (statements) context.addPrecedingStatements(statements);
}
return lua.createNilLiteral();
};