How to generate Getter and Setter for Typescript in VSCode

This feature is shipped builtin with Visual Studio Code 1.24 (May 2018); see here: https://code.visualstudio.com/updates/v1_24#_generate-gettersetter-refactoring

Basically you select the line with the property, then a Quick Action bulb is shown which you have to click. Then you can generate the getters/setters.


The shortcut is Ctrl+Shift+R after highlighting the property.

Longer method: Right click on the property. Then click on refactor from the popup menu.

Currently, vscode has no feature to mass generate getters and setters for all class properties at once like in other IDEs so it has to be done one property at a time.


A VS Code plugin that works to create Java style getters and setters (accessor and mutator methods) is Wilson Godoi's TypeScript's Getters and Setters Object Oriented Programming Style.

https://marketplace.visualstudio.com/items?itemName=Wilson-Godoi.wg-getters-and-setters

enter image description here