Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d802a6

Browse filesBrowse files
author
Andy
authored
Have isObjectBindingPatternElementWithoutPropertyName return the binding element (microsoft#16956)
1 parent 81f8151 commit 2d802a6
Copy full SHA for 2d802a6

1 file changed

+8-6Lines changed: 8 additions & 6 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/findAllReferences.ts‎

Copy file name to clipboardExpand all lines: src/services/findAllReferences.ts
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,16 +593,18 @@ namespace ts.FindAllReferences.Core {
593593
checker.getPropertySymbolOfDestructuringAssignment(<Identifier>location);
594594
}
595595

596-
function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean {
596+
function getObjectBindingElementWithoutPropertyName(symbol: Symbol): BindingElement | undefined {
597597
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
598-
return bindingElement &&
598+
if (bindingElement &&
599599
bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern &&
600-
!bindingElement.propertyName;
600+
!bindingElement.propertyName) {
601+
return bindingElement;
602+
}
601603
}
602604

603605
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined {
604-
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
605-
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
606+
const bindingElement = getObjectBindingElementWithoutPropertyName(symbol);
607+
if (bindingElement) {
606608
const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent);
607609
return typeOfPattern && checker.getPropertyOfType(typeOfPattern, unescapeLeadingUnderscores((<Identifier>bindingElement.name).text));
608610
}
@@ -641,7 +643,7 @@ namespace ts.FindAllReferences.Core {
641643

642644
// If symbol is of object binding pattern element without property name we would want to
643645
// look for property too and that could be anywhere
644-
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
646+
if (getObjectBindingElementWithoutPropertyName(symbol)) {
645647
return undefined;
646648
}
647649

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.