@@ -165,6 +165,8 @@ namespace ts {
165165 return visitVariableStatement ( node as VariableStatement ) ;
166166 case SyntaxKind . ComputedPropertyName :
167167 return visitComputedPropertyName ( node as ComputedPropertyName ) ;
168+ case SyntaxKind . CallExpression :
169+ return visitCallExpression ( node as CallExpression ) ;
168170 default :
169171 return visitEachChild ( node , visitor , context ) ;
170172 }
@@ -606,6 +608,40 @@ namespace ts {
606608 return visitEachChild ( node , visitor , context ) ;
607609 }
608610
611+ function visitCallExpression ( node : CallExpression ) {
612+ if ( isPrivateNamedPropertyAccess ( node . expression ) ) {
613+ // Transform call expressions of private names to properly bind the `this` parameter.
614+ let exprForPropertyAccess : Expression = node . expression . expression ;
615+ let receiver = node . expression . expression ;
616+ if ( ! isSimpleInlineableExpression ( node . expression . expression ) ) {
617+ const generatedName = getGeneratedNameForNode ( node ) ;
618+ hoistVariableDeclaration ( generatedName ) ;
619+ exprForPropertyAccess = setOriginalNode (
620+ createAssignment ( generatedName , exprForPropertyAccess ) ,
621+ node . expression . expression
622+ ) ;
623+ receiver = generatedName ;
624+ }
625+ return visitNode (
626+ updateCall (
627+ node ,
628+ createPropertyAccess (
629+ updatePropertyAccess (
630+ node . expression ,
631+ exprForPropertyAccess ,
632+ node . expression . name
633+ ) ,
634+ "call"
635+ ) ,
636+ /*typeArguments*/ undefined ,
637+ [ receiver , ...node . arguments ]
638+ ) ,
639+ visitor
640+ ) ;
641+ }
642+ return visitEachChild ( node , visitor , context ) ;
643+ }
644+
609645 function enableSubstitutionForClassAliases ( ) {
610646 if ( ( enabledSubstitutions & ESNextSubstitutionFlags . ClassAliases ) === 0 ) {
611647 enabledSubstitutions |= ESNextSubstitutionFlags . ClassAliases ;
0 commit comments