I'm a long time (15+ years) Visual Studio user and am excited to learn both Typescript and the new leaner, meaner Visual Studio Code. I've been trying to setup VSCode like VS, where when you hit F5 it transpiles to Javascript and launches the debugger.

I've found posts that trigger it on save, or using another shortcut (run via tasks.json) - but I'm really surprised there isn't a way of doing this on such a fundamental command, unless I'm really missing something embarrassingly obvious.

At this point I'm just trying to use the "Hello World" greeter sample checked out directly from Microsoft, where it has a manual step of tsc --sourcemap greeter.ts. I just want that to happen automatically, like it does in VS, on any files that need transpiling before I start to run / debug.

So tsc compiler seems pretty slow, takes about 4-5 seconds to transpile on my 2 year old Win10 computer. I see the benefit of TypeScript - Watch Mode so it could it's transpiling as you hit Save. Otherwise, if you transpile everytime before you debug, it doesn't seem to detect whether it needs a transpile or not, so this is the ideal scenario that matches what Visual Studio developers are used to.

Essentially VS Code allows you to create tasks to automate development processes (cleaning files/folders, compiling, bundling, etc.) and also allows you to create environment configurations to run your project.

To have them work together the environment configuration allows specification of a preLaunchTask which will run the defined task before debugging. To create a workflow similar to Visual Studio you could create a compile task and run the task before the debugger by setting it as the preLaunchTask.

The easiest way to do this is simply hit F5. The first time you run it will ask to "Select an environment", if you have already created a launch.json file and would like to start fresh, delete the file. For TypeScript I normally choose node.js which will allow you to run in process or within a web context with frameworks such as express.

So I didn't quite use your exact config files, but followed the documentation plus some of @Burt_Harris suggestions to be able to answer my own question.
– user3147973Sep 26 '16 at 19:20

Excellent, glad you were able to get setup. It took me some time to get use to Visual Studio Code but now that I have it's my default IDE for anything outside the .NET stack (haven't attempted to start compiling C# within VS Code).
– Jesse JohnsonSep 27 '16 at 0:47

If .vscode/tasks.json is not already configured, a message will give you the option to Configure Task Runner, press that button.

Choose one of the two predefined TypeScript options.

You can close the tasks.json window this opened up.

After having tried both TypeScript options, I prefer the ... in watch mode option. That way, after starting the background process with Ctrl+Shift+B once, incremental transpiles happen whenever a file is saved, making launching the program for debugging that much faster...