Skip to content Skip to sidebar Skip to footer

How To Make Visual Studio Javascript Formatting Work?

For some reason Visual Studio javascript formatting does not understand the syntax: (function(){ })(); I'm getting 'expected expression' in the second character of this line: })(

Solution 1:

It seems that in order to make the Visual Studio JS compiler happy, you need to have the "(function(){" be the first line of code in your .js file. You can precede it with comments/whitespace, if you'd like, but no code before it.

Sorry, I can't explain why it is that way but it should fix your problem.

Solution 2:

Try the following:

(function () {

} ());

i.e., I've moved the function argument brackets inside the overall brackets.

Solution 3:

Use following shortcut:

ctrlk+d

Solution 4:

I had to terminate all Node.exe tasks. After reopening my Javascript files, the ctrl+k,ctrl+d started working again. (Visual Studio 2017)

Post a Comment for "How To Make Visual Studio Javascript Formatting Work?"