findAllReferences: Fix declarationIsWriteAccess for PropertyAssignment in destructuring (#26949)

This commit is contained in:
Andy 2018-09-06 15:24:07 -07:00 committed by GitHub
parent a0ebbfb8f0
commit c401d63c5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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:

View file

@ -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");