Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename/refactor variable in VSCode without getting alias `oldName as newName`

VSCode has an option to change/rename variables called editor.action.rename, usually bound to F2.

However, in Typescript and Javascript, this uses aliases when renaming an imported variable, eg:

import { originalName } from 'my-package'

results in

import { originalName as newName } from 'my-package'

How to prevent this, and propagate the change to all references?

like image 894
Highmastdon Avatar asked Sep 08 '25 10:09

Highmastdon


1 Answers

It is possible to prevent renaming using aliases:

  • open your settings file (JSON): CMD+SHIFT+P and select Preferences: Open Settings (JSON)
  • add the following lines
    "javascript.preferences.useAliasesForRenames": false,
    "typescript.preferences.useAliasesForRenames": false,
    
like image 111
Highmastdon Avatar answered Sep 10 '25 03:09

Highmastdon