Although being relatively new Visual Studio Code has already gathered much attention since its publication in November 2015. At first glance you could believe that Visual Studio Code was just another iteration inside the Visual Studio family, but that is not the case. Visual Studio Code is a completely new phenomenon and does not have much in common with its namesakes, except for its actual name.
Why use Visual Studio Code?
Visual Studio Code can be used freely (under MIT-licence), it is open source, and runs on multiple platforms. All of this is quite remarkable for a product made by Microsoft, whose products are mostly proprietary, and for the most part only run on Windows.
- DebuggingAuto completion
- Multi cursor editing
- Split-screen editing
- Git integration
Developing TypeScript with Visual Studio Code
In order to properly use Visual Studio Code with TypeScript a TypeScript config-file (
tsconfig.json in the root folder of a projects signals Visual Studio Code that it is a TypeScript project.
Just like any other modern code editor, Visual Studio Code offers suggestions to auto complete your code while writing. If you have installed the typing-definitions for the libraries/frameworks you are using, Visual Studio Code will offer auto completion for those as well.
If a function call does not match the given typing definition Visual Studio Code will produce a warning.
Before you can use the debugger in Visual Studio Code to its full extent you first need to configure your project to use SourceMaps.
"sourceMap": true entry under the
compilerOptions within the
Finally, you have to instruct the debugger to use SourceMaps by editing the debug task of Visual Studio Code and setting the option
Breakpoints allow to pause the execution of a program at a specific line. This way you can inspect variables without a hurry, and it allows you to comprehend the program flow much better. You might want the program to pause only when a variable takes on a certain value. For that Visual Studio Code allows you to set a condition to the breakpoint itself.
In the example above the execution will only be paused if “user.name” takes on the value “john.doe”.
In order to do that you need to tweak the launch configuration of Visual Studio Code. For the value
program you need to enter the path to your testing program. For a NodeJS project that is to be tested with jasmine-node, the complete entry would be
Now, if one of your test cases would fail, you could use the debugger of Visual Studio Code to get to the root of the problem.
I hope this gives you an insight into why I think Visual Studio Code is a good companion for TypeScript projects. With the debugger being integrated, the seamless integration of TypeScript and the Git-connection it is possible to cover a lot of working steps with a single application.
Finally, choosing the right editor for oneself is a very personal decision. If you have had a bad experience with Visual Studio products (or Microsoft products in general) it is understandable to want to avoid them all together. But I actually think anybody could benefit from giving this interesting new editor a try.