From c882abb6d5d5a602760845982cb5ade0e1de8d7b Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Sat, 17 Mar 2018 11:18:56 -0700 Subject: [PATCH] Add instructions for VS Code (#554) --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 102ae7b53..e79ce8d82 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,25 @@ ts-node node_modules/tape/bin/tape [...args] gulp ``` +### Visual Studio Code + +Create a new node.js configuration, add `-r ts-node/register` to node args and move the `program` to the `args` list (so VS Code doesn't look for `outFiles`). + +```json +{ + "type": "node", + "request": "launch", + "name": "Launch Program", + "runtimeArgs": [ + "-r", + "ts-node/register" + ], + "args": [ + "${workspaceFolder}/index.ts" + ] +} +``` + ## How It Works **TypeScript Node** works by registering the TypeScript compiler for the `.ts`, `.tsx` and, with `allowJs` enabled, `.js` extensions. When node.js has a file extension registered (the `require.extensions` object), it will use the extension internally for module resolution. When an extension is unknown to node.js, it will handle the file as `.js` (JavaScript).