Learn TypeScript development in Visual Studio Code
Visual Studio Code makes coding easier, faster, and less frustrating.
Visual Studio Code is a code editor favored by many programmers who appreciate its wide range of features and its open source heritage. Visual Studio Code makes coding easier, faster, and less frustrating. That's especially true when it comes to TypeScript, which Visual Studio Code supports out of the box.
Features like code completion, parameter hints, and syntax highlighting go a long way toward making TypeScript developers more productive in Visual Studio Code. It also comes with a built-in Node.js debugger and can compile TypeScript to JavaScript from the editor. However, some of these features need to be configured for the best experience.
How to configure Visual Studio Code for TypeScript development#
This step-by-step tutorial shows how to set up Visual Studio Code for TypeScript development. We initialize a Node.js project in TypeScript, write some code, and then compile, run, and debug it, all in Visual Studio Code. Finally, we add ESLint to catch problems as you type. The steps were tested with TypeScript 7.0, Node.js 24, and ESLint 10.
Prerequisites#
Before getting started, make sure you have:
- Node.js installed. See our guide on how to install Node.js if you need it.
- Visual Studio Code downloaded and installed.
You need Node.js and npm, the Node.js package manager that comes with it, to build your TypeScript project. You can verify that Node.js is installed on your machine with the following terminal command:
node -vThat should return the version of Node.js on your machine, like this:
v24.20.0Now let's get started with TypeScript in Visual Studio Code!
Create a TypeScript project#
Let's create a simple Node.js TypeScript project called hello-world. Open your terminal, and create a folder for your project:
mkdir hello-world
cd hello-worldInside hello-world, initialize a project with the following npm command:
npm init -yThis creates a package.json config file for your Node.js project. Time to see what the project consists of in Visual Studio Code!
Launch Visual Studio Code and select File > Open Folder…
In the window that pops up, select the hello-world project folder and click Open. Your project should look something like this:

Currently, the project consists of only the package.json file initialized by npm init.
Install the TypeScript compiler#
Visual Studio Code supports TypeScript development, but it doesn't include the TypeScript compiler, tsc. The TypeScript compiler checks your code for type errors and transpiles it to JavaScript, which you can then run with Node.js or in a browser.
Select View > Terminal in the Visual Studio Code menu to open the editor's integrated terminal. There, install TypeScript and the type definitions for Node.js as development dependencies of your project:
npm install -D typescript @types/nodeInstalling TypeScript in the project, rather than globally, means everyone who works on the project uses the same version. You run it with npx. Verify the installed version:
npx tsc --versionYou should see something like Version 7.0.2. TypeScript 7.0 is the native version of the compiler, written in Go, which is about 10 times faster than earlier versions. Learn more in our article on what's new in TypeScript 7.0.
Configure the TypeScript compiler#
Next, run this command in the terminal:
npx tsc --initThis creates a TypeScript configuration file named tsconfig.json in the project directory. It tells the compiler which files to compile, where to put the output, and how strictly to check your code.
Open tsconfig.json in Visual Studio Code. TypeScript 7.0 generates a short file with sensible defaults, such as "strict": true and "sourceMap": true, and comments that explain how to adjust it. Make these changes at the top of the file:
-
Uncomment the
rootDirandoutDiroptions, so the compiler reads your code from the src folder and writes the JavaScript to the dist folder:"rootDir": "./src", "outDir": "./dist", -
Replace the line
"types": [],with the options for Node.js, which are already in the file as comments:"lib": ["esnext"], "types": ["node"],
The top of your tsconfig.json file now looks like this:
{
"compilerOptions": {
// File Layout
"rootDir": "./src",
"outDir": "./dist",
// Environment Settings
"module": "nodenext",
"target": "esnext",
"lib": ["esnext"],
"types": ["node"],
// Other Outputs
"sourceMap": true,
...
}
}Here's why these options matter:
- The
outDiroption keeps the compiled files in a separate folder, instead of mixing them with your source code. - The
typesoption tells TypeScript which type definitions to load. Since TypeScript 6.0, it doesn't load the packages in node_modules/@types automatically, so without"node"here, evenconsole.log()fails withCannot find name 'console'. - The
sourceMapoption, which is on by default, generates .js.map files that map the compiled JavaScript back to your TypeScript. The Visual Studio Code debugger uses them so that you can set breakpoints in your TypeScript files.
Your TypeScript project is almost ready to be compiled. But first, you need TypeScript code.
Right-click in the Explorer section, select New Folder…, and name it src. Then right-click the src folder, select New File…, type index.ts, and press Enter. Add the following code to src/index.ts:
const message: string = "Hello, World!";
console.log(message);This snippet simply prints the well-known Hello, World! message.
Try IntelliSense for code completion#
When you were writing the lines above in Visual Studio Code, you might have noticed some code suggestions made by the editor. This happens because of IntelliSense, one of Visual Studio Code's most useful features.
IntelliSense includes features like code completion, documentation on hover, and parameter info for functions. It suggests how to complete the code as you type, which can significantly improve your productivity and accuracy. You can see it in action here:

Visual Studio Code comes with IntelliSense support for TypeScript out of the box, so you don't have to configure it. To use the faster TypeScript 7.0 language service in the editor, install the TypeScript 7 extension from the TypeScript team, formerly called TypeScript Native Preview.
Now that you've written some TypeScript, let's compile it and see if it works.
Compiling TypeScript in Visual Studio Code#
Open the integrated terminal in Visual Studio Code and run:
npx tsc -p .This compiles all TypeScript files in the project to JavaScript. The -p . option tells the compiler to use the tsconfig.json file in the current directory, which is also what npx tsc does by default. The output, including index.js and the source map index.js.map, is written to the dist folder.
You can confirm that the compiled JavaScript code works with this command in the terminal:
node dist/index.jsNode.js runs index.js and prints:
Hello, World!Another way to start the compiler is to select Terminal > Run Build Task… in the Visual Studio Code menu, and click the tsc: build - tsconfig.json option.

This runs the same build as tsc -p ., directly from the editor. The tsc: watch - tsconfig.json option starts the compiler in watch mode, which recompiles your code every time you save a file.
Node.js 24 can also run TypeScript files directly by stripping the type annotations, so node src/index.ts prints the same message without a build step. It doesn't check types, though, so you still need tsc to catch type errors.
Run and debug TypeScript in Visual Studio Code#
Visual Studio Code supports TypeScript debugging with its built-in Node.js debugger. To set it up, click the Run and Debug icon on the sidebar, click create a launch.json file, and select Node.js.

This creates a default launch.json file in the project's .vscode folder. It's the configuration file that the Visual Studio Code debugger uses to launch and debug an application: it specifies how to start the application, the arguments to use, and the environment variables to set.
Open that file and edit it as follows:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/src/index.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}Here's what the important options do:
programis the entry point of the application to debug. For a TypeScript project, it's your main TypeScript file.preLaunchTaskis the name of the Visual Studio Code task to run before launching the application. Here, it's the TypeScript build task, so the debugger always runs your latest code.outFilestells the debugger where to find the compiled JavaScript files. The debugger runs them, and uses the source maps generated by"sourceMap": trueto map them back to your TypeScript code, so you can debug the TypeScript directly.
Save the launch.json file and open src/index.ts. Click the blank space to the left of the line number of the console.log() line to set a breakpoint. A red dot appears next to the line:

When you run the code with the debugger, the execution stops there. This lets you check that the Node.js debugger in Visual Studio Code works as expected.
Go to the Run and Debug section again and click the green play button to start the debugger. Visual Studio Code runs the build task, then launches the program, and execution stops at the breakpoint.

On the left, you can see the values of the variables at the breakpoint. You can also pause, step over, step in and out, restart, and stop the program, as described in the Visual Studio Code debugging documentation.
Press F5 to resume the execution, and you should see the following message in the Debug Console tab:
Hello, World!This is what you expect the application to produce, which means the program ran correctly.
You just learned how to set up Visual Studio Code for TypeScript programming. There's one more thing that makes writing quality TypeScript code easier: a linter.
How to configure ESLint in Visual Studio Code#
You can extend Visual Studio Code with extensions, which add features to the editor. One of the most popular extensions for TypeScript development is the ESLint extension.
ESLint is a static code analysis tool for JavaScript and TypeScript that helps you find and fix common problems, such as unused variables, and enforce consistent code. With typescript-eslint, it understands TypeScript code. The extension runs ESLint directly in the editor, so you see problems as you type.
Let's add ESLint to your TypeScript project.
1. Install ESLint and typescript-eslint#
typescript-eslint uses the TypeScript compiler's JavaScript API, which TypeScript 7.0 doesn't include yet, so it can't use TypeScript 7.0. If you try to install it in a project with TypeScript 7.0, npm stops with an ERESOLVE error, because typescript-eslint requires a TypeScript version lower than 6.1.
Until a new API arrives, you can install TypeScript 6.0 and 7.0 side by side. This command installs TypeScript 6.0 under the typescript name, for tools like typescript-eslint, and TypeScript 7.0 under the @typescript/native name:
npm install -D "typescript@npm:@typescript/typescript6@^6.0.2" "@typescript/native@npm:typescript@^7.0.2"With this setup, npx tsc still runs TypeScript 7.0, so your builds stay fast, and tools that import the typescript package get TypeScript 6.0.
Now install ESLint, its recommended JavaScript rules, and typescript-eslint:
npm install -D eslint @eslint/js typescript-eslint2. Create the ESLint configuration#
Create a file named eslint.config.mjs in the project's root directory:
// @ts-check
import eslint from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
export default defineConfig(
{ ignores: ['dist/'] },
eslint.configs.recommended,
tseslint.configs.recommended,
);This is ESLint's flat config format, which replaces the old .eslintrc.json files. It ignores the compiled files in dist, and turns on ESLint's recommended rules and typescript-eslint's recommended rules for TypeScript.
You can also generate a configuration interactively with npm init @eslint/config@latest, which asks you a few questions and installs the packages you need.
To check that ESLint works, add a line with a few problems to src/index.ts:
let unused: any = 1;Then run ESLint in the terminal:
npx eslint .ESLint reports three problems:
src/index.ts
2:5 error 'unused' is never reassigned. Use 'const' instead prefer-const
2:5 error 'unused' is assigned a value but never used @typescript-eslint/no-unused-vars
2:13 error Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
✖ 3 problems (3 errors, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.Remove the line before you continue.
3. Install the ESLint extension#
Now install the ESLint extension in Visual Studio Code. Click the Extensions icon in the sidebar and search for ESLint. Find the ESLint extension by Microsoft and click Install.

The extension finds your eslint.config.mjs file automatically, and underlines problems in your TypeScript files as you type.
To also fix the problems ESLint can fix automatically every time you save a file, create a settings.json file in the .vscode folder with the following content:
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}The settings.json file in .vscode contains settings for this project, which override your global Visual Studio Code settings. The "explicit" value runs the fixes when you save a file manually, but not when Visual Studio Code saves it automatically.
Now, when you save index.ts, ESLint fixes problems like a let that should be a const, and highlights the ones you need to fix yourself. Nothing can stop you from writing quality code!
Summary#
Configuring Visual Studio Code for TypeScript development is fairly straightforward. You just learned how to create a Node.js project in TypeScript, load it in Visual Studio Code, and use the editor to write code with IntelliSense. You also configured the TypeScript compiler, set up the Node.js debugger to debug TypeScript code, and added ESLint to the project.
When your Node.js app is ready to go live, you can deploy it from Git with Sevalla's Application Hosting, and add a managed database with Database Hosting.