mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Have isObjectBindingPatternElementWithoutPropertyName return the binding element (#16956)
This commit is contained in:
parent
81f8151e3a
commit
2d802a62c4
@ -593,16 +593,18 @@ namespace ts.FindAllReferences.Core {
|
||||
checker.getPropertySymbolOfDestructuringAssignment(<Identifier>location);
|
||||
}
|
||||
|
||||
function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean {
|
||||
function getObjectBindingElementWithoutPropertyName(symbol: Symbol): BindingElement | undefined {
|
||||
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||
return bindingElement &&
|
||||
if (bindingElement &&
|
||||
bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern &&
|
||||
!bindingElement.propertyName;
|
||||
!bindingElement.propertyName) {
|
||||
return bindingElement;
|
||||
}
|
||||
}
|
||||
|
||||
function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined {
|
||||
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
|
||||
const bindingElement = getDeclarationOfKind<BindingElement>(symbol, SyntaxKind.BindingElement);
|
||||
const bindingElement = getObjectBindingElementWithoutPropertyName(symbol);
|
||||
if (bindingElement) {
|
||||
const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent);
|
||||
return typeOfPattern && checker.getPropertyOfType(typeOfPattern, unescapeLeadingUnderscores((<Identifier>bindingElement.name).text));
|
||||
}
|
||||
@ -641,7 +643,7 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
// If symbol is of object binding pattern element without property name we would want to
|
||||
// look for property too and that could be anywhere
|
||||
if (isObjectBindingPatternElementWithoutPropertyName(symbol)) {
|
||||
if (getObjectBindingElementWithoutPropertyName(symbol)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user