TypeScript rename variable

2019-04-19 18:24发布

Anders Hejlsberg shows on channel9 that you can rename variables across multiple files with the Visual Studio TypeScript plugin. cf.: video introduction to TypeScript by Anders Hejlsberg at 50:08.

However, when I open the Refactoring menu, all items are deactivated, including Rename. I'm using the latest version of VS2012 Professional. Maybe this is related to ReSharper which is installed on my system. Can anybody could confirm this as a bug or is the Rename feature still in development?

Edit since I may not post this as an answer:

ReSharper overrides some original Visual Studio menu items. There is a checkbox at RESHARPER -> Options -> Keyboard & Menus -> Hide overriden Visual Studio menu items.

Check this and the original Refactoring menu shows up again. There is the Rename feature which is working just fine.

2条回答
霸刀☆藐视天下
2楼-- · 2019-04-19 19:13

There are two reasons you may not be able to refactor the name in Visual Studio.

  1. If you are running your application in debug mode, many editing features are not available

  2. If you have a Visual Studio extension, such as Resharper, it may have overridden the Visual Studio feature in the menu, or shortcut keys. For rename, the Visual Studio shortcut is simply F2, so it shouldn't clash with the Resharper key-combination - but Resharper may still override the context menu.

查看更多
看我几分像从前
3楼-- · 2019-04-19 19:24

ReSharper (7.1.1) doesn't have built-in rename support for TypeScript. If you have ReSharper installed it is probably overriding (and hiding) Visual Studio's native rename -- this is the default functionality.

To show and enable Visual Studio's rename you need to uncheck the following option:

RESHARPER -> Options -> Keyboard & Menus -> Hide overriden Visual Studio menu items

(Per the comments to this post, you can vote for this feature to be added to ReSharper at the following link: http://youtrack.jetbrains.com/issue/RSRP-330454)

查看更多
登录 后发表回答