Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>TypeScript RefactorsNew to Visual Studio Code? Get it now.
TypeScript Refactors

TypeScript Refactors

cancerberosgx

|
7,480 installs
| (0) | Free
Contributes with several TypeScript Language Service Plugins that add refactors for agile source code development. [See details and demos here](https://github.com/cancerberoSgx/typescript-plugins-of-mine/tree/master/typescript-plugin-proactive-code-fixes).
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

typescript-refactors

Has several TypeScript plugins for agile code development. Most refactors and fixes are maintained in other projects, so please go there for latest documentation and demo:

  • typescript-plugin-proactive-code-fixes

Fixes and Refactors

A lot is still to be fixed and implemented but we have several helpful and stable fixes working already:

Fixing and refactoring variables

  • Variable declaration list split in different stataments and viceversa
  • Declare missing variable
  • Rename duplicated variables
  • Put a name to a function declaration without one
  • Change const to let when reassigning a const variable
  • Remove readonly keyword of property declaration when trying to modify it

Implementing types / prototyping

  • Declare classes and interfaces when trying to extend or implement something that doesn't exist
  • Declare an interface from return value
  • Declare missing constructors when calling new A(a,b) on a class/interface that doesn't declare it
  • Declare interface from return value
  • Fix object literal so it implements its interface or class. It will adding / remove or change object literal members so it comply with its interface or class
  • declare member - complements the code fix already existing in typescript to fullfill all cases. declaring missing properties / methods
  • add missing return statement
  • Declare missing classes and interfaces
  • Make member public (change the scope of a member when expression is trying to access it)

Refactoring

  • Transform parameter list into single "named" parameter. Splits variable declaration list in individual variable statements.
  • Arrow Functions - add / remove body braces.
  • Extract interface from class or object literal declaration.
  • Delegate Methods to Property
  • Transform string concatenation into string templates and viceversa

Formatting

  • change string literal quotes
  • remove empty lines form selected region

Details and demo

Variable related fixes and refactors

Quick fixes when you forgot to declare variables, have duplicates, reassigning a constant or need to transform a list of variable declarations into single declaration statements, etc:

Variable related fixes and refactors

Arrow Functions add / remove braces

(a quick way of getting the shorter expression of current arrow function and also add braces and parens to already shorted arrow functions)

Arrow Function - remove - add body braces vscode editor demo

Extract interface from class or object literal declaration

Extract interface from class or object literal declaration vscode editor demo

Delegate Methods to Property

When you want to expose the methods of a property in parent class or interface. Suggested when standing in a class or interface property.

Delegate Methods to Property-  vscode editor demo

String concatenation to templates and viceversa

String concatenation to templates and viceversa -  vscode editor demo

Declare classes and interfaces

No much to say here - if you extends or implements an class or interface that is not declared yet the refactor will suggest you to declare it.

Declare classes and interfaces vscode demo

Declare constructors

Basic refactor of any descent strongly typed language IDE

vscode demo creating variables and constructors declarations

Declare interfaces from return values

Useful for quickly prototype interfaces when writing the implementation.

  • Visual Studio Code Editor

Declare interfaces from return values - Visual Studio Code Editor

  • Atom Editor

Declare interfaces from return values - Atom Editor

and more to come!!

(TODO: if we add some vscode concrete UI implementations then we should put those demos here. But right now there is nothing vscode-particular implemented.)

Extension Settings

No settings yet.

Known Issues

  • Please save the file before applying any refactor. In general they behave OK, but just in case it's good idea to save the ile first so there's no de synchronization.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft