@@ -151,6 +151,8 @@ namespace ts {
151
151
return visitComputedPropertyName ( node as ComputedPropertyName ) ;
152
152
case SyntaxKind . PropertyAccessExpression :
153
153
return visitPropertyAccessExpression ( node as PropertyAccessExpression ) ;
154
+ case SyntaxKind . CallExpression :
155
+ return visitCallExpression ( node as CallExpression ) ;
154
156
default :
155
157
return visitEachChild ( node , visitor , context ) ;
156
158
}
@@ -571,6 +573,40 @@ namespace ts {
571
573
return node ;
572
574
}
573
575
576
+ function visitCallExpression ( node : CallExpression ) {
577
+ if ( isPrivateNamedPropertyAccess ( node . expression ) ) {
578
+ // Transform call expressions of private names to properly bind the `this` parameter.
579
+ let exprForPropertyAccess : Expression = node . expression . expression ;
580
+ let receiver = node . expression . expression ;
581
+ if ( ! isSimpleInlineableExpression ( node . expression . expression ) ) {
582
+ const generatedName = getGeneratedNameForNode ( node ) ;
583
+ hoistVariableDeclaration ( generatedName ) ;
584
+ exprForPropertyAccess = setOriginalNode (
585
+ createAssignment ( generatedName , exprForPropertyAccess ) ,
586
+ node . expression . expression
587
+ ) ;
588
+ receiver = generatedName ;
589
+ }
590
+ return updateCall (
591
+ node ,
592
+ createPropertyAccess (
593
+ visitNode (
594
+ updatePropertyAccess (
595
+ node . expression ,
596
+ exprForPropertyAccess ,
597
+ node . expression . name
598
+ ) ,
599
+ visitor
600
+ ) ,
601
+ "call"
602
+ ) ,
603
+ /*typeArguments*/ undefined ,
604
+ [ visitNode ( receiver , visitor ) , ...visitNodes ( node . arguments , visitor ) ]
605
+ ) ;
606
+ }
607
+ return visitEachChild ( node , visitor , context ) ;
608
+ }
609
+
574
610
function enableSubstitutionForClassAliases ( ) {
575
611
if ( ( enabledSubstitutions & ESNextSubstitutionFlags . ClassAliases ) === 0 ) {
576
612
enabledSubstitutions |= ESNextSubstitutionFlags . ClassAliases ;
0 commit comments