@@ -271,12 +271,9 @@ export const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node
271271 ) ;
272272 }
273273
274- const signatureDeclaration = signature ?. getDeclaration ( ) ;
275-
276274 let callPath : lua . Expression ;
277275 let parameters : lua . Expression [ ] ;
278- const isContextualCall =
279- ! signatureDeclaration || getDeclarationContextType ( context , signatureDeclaration ) !== ContextType . Void ;
276+ const isContextualCall = isContextualCallExpression ( context , signature ) ;
280277 if ( ! isContextualCall ) {
281278 [ callPath , parameters ] = transformCallAndArguments ( context , calledExpression , node . arguments , signature ) ;
282279 } else {
@@ -288,8 +285,7 @@ export const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node
288285 calledExpression ,
289286 node . arguments ,
290287 signature ,
291- // Only pass context if noImplicitSelf is not configured
292- context . options . noImplicitSelf ? undefined : callContext
288+ callContext
293289 ) ;
294290 }
295291
@@ -300,6 +296,14 @@ export const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node
300296 return wrapResultInTable ? wrapInTable ( callExpression ) : callExpression ;
301297} ;
302298
299+ function isContextualCallExpression ( context : TransformationContext , signature : ts . Signature | undefined ) : boolean {
300+ const declaration = signature ?. getDeclaration ( ) ;
301+ if ( ! declaration ) {
302+ return ! context . options . noImplicitSelf ;
303+ }
304+ return getDeclarationContextType ( context , declaration ) !== ContextType . Void ;
305+ }
306+
303307export function getCalledExpression ( node : ts . CallExpression ) : ts . Expression {
304308 function unwrapExpression ( expression : ts . Expression ) : ts . Expression {
305309 expression = ts . skipOuterExpressions ( expression ) ;
0 commit comments