Skip to content
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

Allow rename aliasing behaviour to be controlled on per-command basis #93501

Closed
OliverJAsh opened this issue Mar 26, 2020 · 3 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Mar 26, 2020

VS Code version: 1.43.2
OS: macOS 10.15.4

Originally suggested here: microsoft/TypeScript#29238 (comment)

With regards to TypeScript renames, I understand that VS Code defaults to the safe behaviour of creating aliases where shorthand properties are used (i.e. javascript.preferences.renameShorthandProperties and typescript.preferences.renameShorthandProperties default to true).

However, sometimes (not always) I want the rename to apply everywhere—I don't want any aliases to be created. React component props are a good example (microsoft/TypeScript#29238 (comment)):

type State = {};
type Props = { foo: string };
const Component = ({ foo }: Props) => {
    console.log(foo);
};

If I rename the prop foo anywhere, in Props or in Component, an alias will be created, but in this specific case I always want the prop to be renamed everywhere (in mapStateToProps and Component).

Another example is renaming imports. Sometimes I only want to rename the symbol in this file, which the default behaviour allows me to do (by creating an alias):

import { other } from './other';
// after renaming: import { other as other2 } from './other';

… but most of the time I want to rename the symbol everywhere, including at the definition.

I can change the behaviour by flicking the switch—setting renameShorthandProperties to false or true depending on what I want at the time—however it's far from a smooth experience if I have to go into my settings to temporarily adjust a setting before executing the rename.

Perhaps VS Code could provide two rename commands instead of one, so that the behaviour can be controlled on a per-command basis?

Related:

@microsoft microsoft deleted a comment Mar 26, 2020
@mjbvz mjbvz self-assigned this Mar 26, 2020
@mjbvz mjbvz added feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues labels Mar 26, 2020
@vscodebot vscodebot bot added this to the Backlog Candidates milestone Mar 26, 2020
@vscodebot
Copy link

vscodebot bot commented Mar 26, 2020

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

3 participants
@OliverJAsh @mjbvz and others