Repository navigation
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:
- Option to disable aliased JS/TS destructured property renaming TypeScript#29238
- https://code.visualstudio.com/updates/v1_30#_renames-handle-jsts-destructuring-properly
- Rename of import should be a local rename TypeScript#14039
- When renaming an imported symbol, rename only in current file TypeScript#28406
- Allow per-file setting for rename default behavior preferences TypeScript#29593
- Support TypeScript Server's per-file setting for rename configuration #68029
- Suggestion: refactor to "renamed" named import TypeScript#28367
- Rename a symbol of a named export: Do not create export alias TypeScript#29026
Activity
vscodebot commentedon 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!
vscode-triage-bot commentedon May 16, 2020
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
vscode-triage-bot commentedon May 26, 2020
🙁 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!