Search code examples
javascripttypescriptvisual-studio-codecode-formatting

VS Code code formatting for TypeScript and JavaScript


I'm looking for extensions or JSON settings to format my code given below:

if(true)
{
}
else
{
}

and not like below:

if(true){
} else {
}

Solution

  • I found my answer modified the json setting:

    "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
    "typescript.format.enable": true,
    "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true, 
    "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
    
    "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
    "typescript.format.placeOpenBraceOnNewLineForFunctions": true,