@@ -167,6 +167,8 @@ namespace ts {
167
167
return visitComputedPropertyName ( node as ComputedPropertyName ) ;
168
168
case SyntaxKind . PropertyAccessExpression :
169
169
return visitPropertyAccessExpression ( node as PropertyAccessExpression ) ;
170
+ case SyntaxKind . CallExpression :
171
+ return visitCallExpression ( node as CallExpression ) ;
170
172
default :
171
173
return visitEachChild ( node , visitor , context ) ;
172
174
}
@@ -588,6 +590,40 @@ namespace ts {
588
590
return node ;
589
591
}
590
592
593
+ function visitCallExpression ( node : CallExpression ) {
594
+ if ( isPrivateNamedPropertyAccess ( node . expression ) ) {
595
+ // Transform call expressions of private names to properly bind the `this` parameter.
596
+ let exprForPropertyAccess : Expression = node . expression . expression ;
597
+ let receiver = node . expression . expression ;
598
+ if ( ! isSimpleInlineableExpression ( node . expression . expression ) ) {
599
+ const generatedName = getGeneratedNameForNode ( node ) ;
600
+ hoistVariableDeclaration ( generatedName ) ;
601
+ exprForPropertyAccess = setOriginalNode (
602
+ createAssignment ( generatedName , exprForPropertyAccess ) ,
603
+ node . expression . expression
604
+ ) ;
605
+ receiver = generatedName ;
606
+ }
607
+ return updateCall (
608
+ node ,
609
+ createPropertyAccess (
610
+ visitNode (
611
+ updatePropertyAccess (
612
+ node . expression ,
613
+ exprForPropertyAccess ,
614
+ node . expression . name
615
+ ) ,
616
+ visitor
617
+ ) ,
618
+ "call"
619
+ ) ,
620
+ /*typeArguments*/ undefined ,
621
+ [ visitNode ( receiver , visitor ) , ...visitNodes ( node . arguments , visitor ) ]
622
+ ) ;
623
+ }
624
+ return visitEachChild ( node , visitor , context ) ;
625
+ }
626
+
591
627
function enableSubstitutionForClassAliases ( ) {
592
628
if ( ( enabledSubstitutions & ESNextSubstitutionFlags . ClassAliases ) === 0 ) {
593
629
enabledSubstitutions |= ESNextSubstitutionFlags . ClassAliases ;
0 commit comments