Skip to content

Commit c401d63

Browse files
author
Andy
authored
findAllReferences: Fix declarationIsWriteAccess for PropertyAssignment in destructuring (#26949)
1 parent a0ebbfb commit c401d63

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/services/findAllReferences.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,15 @@ namespace ts.FindAllReferences {
255255
case SyntaxKind.NamespaceExportDeclaration:
256256
case SyntaxKind.NamespaceImport:
257257
case SyntaxKind.Parameter:
258-
case SyntaxKind.PropertyAssignment:
259258
case SyntaxKind.ShorthandPropertyAssignment:
260259
case SyntaxKind.TypeAliasDeclaration:
261260
case SyntaxKind.TypeParameter:
262261
return true;
263262

263+
case SyntaxKind.PropertyAssignment:
264+
// In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.)
265+
return !isArrayLiteralOrObjectLiteralDestructuringPattern((decl as PropertyAssignment).parent);
266+
264267
case SyntaxKind.FunctionDeclaration:
265268
case SyntaxKind.FunctionExpression:
266269
case SyntaxKind.Constructor:

tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
////let p, b;
44
////
5-
////p, [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }];
5+
////p, [{ [|{| "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }];
66

77
verify.singleReferenceGroup("(property) a: any");

0 commit comments

Comments
 (0)