Skip to content

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

Closed

Description

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:

Activity

  1. added this to the Backlog Candidates milestone on Mar 26, 2020
  2. vscodebot commented on Mar 26, 2020

    @vscodebot

    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!

  3. vscode-triage-bot commented on May 16, 2020

    @vscode-triage-bot

    This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding

  4. vscode-triage-bot commented on May 26, 2020

    @vscode-triage-bot

    🙁 In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  5. locked and limited conversation to collaborators on Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionalityjavascriptJavaScript support issuestypescriptTypescript support issues

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions