From c401d63c5f0fb937ce53f499ba3872b24470b0fc Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 6 Sep 2018 15:24:07 -0700 Subject: [PATCH] findAllReferences: Fix declarationIsWriteAccess for PropertyAssignment in destructuring (#26949) --- src/services/findAllReferences.ts | 5 ++++- .../findAllRefsObjectBindingElementPropertyName07.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bcc68162746..81970322c21 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -255,12 +255,15 @@ namespace ts.FindAllReferences { case SyntaxKind.NamespaceExportDeclaration: case SyntaxKind.NamespaceImport: case SyntaxKind.Parameter: - case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.TypeParameter: return true; + case SyntaxKind.PropertyAssignment: + // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) + return !isArrayLiteralOrObjectLiteralDestructuringPattern((decl as PropertyAssignment).parent); + case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.Constructor: diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts index 69d1f6ac2ff..18fa4e43273 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts @@ -2,6 +2,6 @@ ////let p, b; //// -////p, [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; +////p, [{ [|{| "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; verify.singleReferenceGroup("(property) a: any");