@@ -165,6 +165,8 @@ namespace ts {
165
165
return visitVariableStatement ( node as VariableStatement ) ;
166
166
case SyntaxKind . ComputedPropertyName :
167
167
return visitComputedPropertyName ( node as ComputedPropertyName ) ;
168
+ case SyntaxKind . CallExpression :
169
+ return visitCallExpression ( node as CallExpression ) ;
168
170
default :
169
171
return visitEachChild ( node , visitor , context ) ;
170
172
}
@@ -606,6 +608,40 @@ namespace ts {
606
608
return visitEachChild ( node , visitor , context ) ;
607
609
}
608
610
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
+
609
645
function enableSubstitutionForClassAliases ( ) {
610
646
if ( ( enabledSubstitutions & ESNextSubstitutionFlags . ClassAliases ) === 0 ) {
611
647
enabledSubstitutions |= ESNextSubstitutionFlags . ClassAliases ;
0 commit comments