@@ -14615,15 +14615,15 @@ namespace ts {
14615
14615
getAccessedPropertyName(source as PropertyAccessExpression | ElementAccessExpression) === getAccessedPropertyName(target) &&
14616
14616
isMatchingReference((source as PropertyAccessExpression | ElementAccessExpression).expression, target.expression);
14617
14617
case SyntaxKind.BindingElement:
14618
- if (target.kind !== SyntaxKind.PropertyAccessExpression) return false;
14619
- const t = target as PropertyAccessExpression ;
14620
- if (t.name.escapedText !== getBindingElementNameText(source as BindingElement)) return false;
14621
- if (source.parent.parent.kind === SyntaxKind.BindingElement && isMatchingReference(source.parent.parent, t .expression)) {
14622
- return true;
14623
- }
14624
- if (source.parent.parent.kind === SyntaxKind. VariableDeclaration) {
14625
- const maybeId = (source.parent.parent as VariableDeclaration).initializer ;
14626
- return !!maybeId && isMatchingReference(maybeId, t.expression);
14618
+ if (target.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>target).name.escapedText === getBindingElementNameText(<BindingElement>source)) {
14619
+ const ancestor = source.parent.parent ;
14620
+ if (ancestor.kind === SyntaxKind. BindingElement) {
14621
+ return isMatchingReference(ancestor, (<PropertyAccessExpression>target) .expression);
14622
+ }
14623
+ if (ancestor.kind === SyntaxKind.VariableDeclaration) {
14624
+ const initializer = (< VariableDeclaration>ancestor).initializer;
14625
+ return !!initializer && isMatchingReference(initializer, (<PropertyAccessExpression>target).expression) ;
14626
+ }
14627
14627
}
14628
14628
}
14629
14629
return false;
@@ -14635,14 +14635,25 @@ namespace ts {
14635
14635
undefined;
14636
14636
}
14637
14637
14638
+ function getReferenceParent(source: Node) {
14639
+ if (source.kind === SyntaxKind.PropertyAccessExpression) {
14640
+ return (<PropertyAccessExpression>source).expression;
14641
+ }
14642
+ if (source.kind === SyntaxKind.BindingElement) {
14643
+ const ancestor = source.parent.parent;
14644
+ return ancestor.kind === SyntaxKind.VariableDeclaration ? (<VariableDeclaration>ancestor).initializer : ancestor;
14645
+ }
14646
+ return undefined;
14647
+ }
14648
+
14638
14649
function containsMatchingReference(source: Node, target: Node) {
14639
- while (source.kind === SyntaxKind.PropertyAccessExpression) {
14640
- source = (<PropertyAccessExpression>source).expression;
14641
- if (isMatchingReference(source , target)) {
14650
+ let parent = getReferenceParent(source);
14651
+ while (parent) {
14652
+ if (isMatchingReference(parent , target)) {
14642
14653
return true;
14643
14654
}
14655
+ parent = getReferenceParent(parent);
14644
14656
}
14645
- return false;
14646
14657
}
14647
14658
14648
14659
// Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared
0 commit comments