Skip to content

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

@OliverJAsh

Description

@OliverJAsh

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:

Metadata

Metadata

Assignees

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