Search code examples
intellij-ideawebstorm

Avoid new line before closing bracket


It is common with TypeScript to have constructors like this :

export class SlotController {

  /*
   * This injects the dependency and assigns it to a field
   * It is NOT an unused variable
   */
  constructor(private service: SlotService) {}

  [...]
}

Unfortunately, upon automatic reformat, IntelliJ/WebStorm will add a new line before the closing curly bracket :

constructor(private service: SlotService) {
}

I tried these options under Code Styles > TypeScript but it does not seem to work

enter image description here


Solution

  • You can try to enable the following options:

    • Simple blocks in one line
    • Simple methods in one line

    Under Settings/Preferences (on macOS) | Editor | Code Style | TypeScript | Wrapping and Braces | Keep when reformatting