Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
3 commits merged into from
Sep 26, 2018

Conversation

ghost
Copy link

@ghost ghost commented Sep 26, 2018

Fixes #12007

@ghost ghost requested review from sheetalkamat and mjbvz September 26, 2018 00:56
@ghost ghost force-pushed the renameShorthand branch from d8fb299 to 232e353 Compare September 26, 2018 00:59
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
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?

}

export interface RenameTextSpan extends TextSpan {
readonly prefixText: string | undefined;
Copy link
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
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
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

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.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants