fix(39421): omit prefix text for rest binding element (#39433)

This commit is contained in:
Alexander T 2020-07-08 23:25:28 +03:00 committed by GitHub
parent 8795458d6d
commit ebac7ec08f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -402,7 +402,7 @@ namespace ts.FindAllReferences {
const parent = node.parent;
const name = originalNode.text;
const isShorthandAssignment = isShorthandPropertyAssignment(parent);
if (isShorthandAssignment || isObjectBindingElementWithoutPropertyName(parent) && parent.name === node) {
if (isShorthandAssignment || (isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) {
const prefixColon: PrefixAndSuffix = { prefixText: name + ": " };
const suffixColon: PrefixAndSuffix = { suffixText: ": " + name };
if (kind === EntryKind.SearchedLocalFoundProperty) {

View File

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
////interface I {
//// a: number;
//// b: number;
//// c: number;
////}
////function foo([|{ a, ...[|{| "contextRangeIndex": 0 |}rest|] }: I|]) {
//// [|rest|];
////}
const [r0Def, r0, r1] = test.ranges();
verify.renameLocations(r0, { ranges: [r0, r1], providePrefixAndSuffixTextForRename: true });