@@ -36,6 +36,7 @@ export function getTransformers(
3636
3737            ...( transformersFromOptions . after  ??  [ ] ) , 
3838            ...( customTransformers . after  ??  [ ] ) , 
39+             stripParenthesisExpressionsTransformer , 
3940            luaTransformer , 
4041        ] , 
4142    } ; 
@@ -53,6 +54,30 @@ export const noImplicitSelfTransformer: ts.TransformerFactory<ts.SourceFile | ts
5354        : transformSourceFile ( node ) ; 
5455} ; 
5556
57+ export  const  stripParenthesisExpressionsTransformer : ts . TransformerFactory < ts . SourceFile >  =  context  =>  sourceFile  =>  { 
58+     // Remove parenthesis expressions before transforming to Lua, so transpiler is not hindered by extra ParenthesizedExpression nodes 
59+     function  unwrapParentheses ( node : ts . Expression )  { 
60+         while  ( ts . isParenthesizedExpression ( node ) )  { 
61+             node  =  node . expression ; 
62+         } 
63+         return  node ; 
64+     } 
65+     function  visit ( node : ts . Node ) : ts . Node  { 
66+         // For now only call expressions strip their expressions of parentheses, there could be more cases where this is required 
67+         if  ( ts . isCallExpression ( node ) )  { 
68+             return  ts . factory . updateCallExpression ( 
69+                 node , 
70+                 unwrapParentheses ( node . expression ) , 
71+                 node . typeArguments , 
72+                 node . arguments 
73+             ) ; 
74+         } 
75+ 
76+         return  ts . visitEachChild ( node ,  visit ,  context ) ; 
77+     } 
78+     return  ts . visitNode ( sourceFile ,  visit ) ; 
79+ } ; 
80+ 
5681function  loadTransformersFromOptions ( program : ts . Program ,  diagnostics : ts . Diagnostic [ ] ) : ts . CustomTransformers  { 
5782    const  customTransformers : Required < ts . CustomTransformers >  =  { 
5883        before : [ ] , 
0 commit comments