Skip to content

Add 'prefixText' and 'suffixText' when renaming shorthand properties#27356

Merged
3 commits merged intomasterfrom
renameShorthand
Sep 26, 2018
Merged

Add 'prefixText' and 'suffixText' when renaming shorthand properties#27356
3 commits merged intomasterfrom
renameShorthand

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Sep 26, 2018

Fixes #12007

@ghost ghost requested review from mjbvz and sheetalkamat September 26, 2018 00:56
@ghost ghost force-pushed the renameShorthand branch from d8fb299 to 232e353 Compare September 26, 2018 00:59
Comment thread src/harness/harnessLanguageService.ts Outdated
return unwrapJSONCallResult(this.shim.findRenameLocations(fileName, position, findInStrings, findInComments));
const res = unwrapJSONCallResult(this.shim.findRenameLocations(fileName, position, findInStrings, findInComments)) as ReadonlyArray<ts.RenameLocation>;
// JSON serialization removes undefined properties, so add them back if necessary.
return res.map((r): ts.RenameLocation => ({ prefixText: undefined, suffixText: undefined, ...r }));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? Not having those properties should result in same result as having them as undefined?

Comment thread src/server/protocol.ts Outdated
}

export interface RenameTextSpan extends TextSpan {
readonly prefixText: string | undefined;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these optional instead?

@ghost ghost force-pushed the renameShorthand branch 3 times, most recently from ef92a72 to b7e3dbf Compare September 26, 2018 18:56
@ghost ghost force-pushed the renameShorthand branch from b7e3dbf to 6a8f472 Compare September 26, 2018 21:26
Copy link
Copy Markdown
Contributor

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocol changes look good to me. Once this is merged, I'll add basic support in VS Code so users of TS@next can try it out before we pick up TS 3.2

@ghost
Copy link
Copy Markdown
Author

ghost commented Sep 26, 2018

@sheetalkamat Good to merge?

@ghost ghost merged commit 0a97663 into master Sep 26, 2018
@ghost ghost deleted the renameShorthand branch September 26, 2018 23:58
@dhlolo
Copy link
Copy Markdown

dhlolo commented Oct 22, 2023

What if I want to call tsLanguageService.findRenameLocations(...) to rename the key of short hand property? It seems that I cannot use this api to achieve my goal right now.

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants