Open In App

Setup a TypeScript Project

Last Updated : 29 Sep, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Step 1: Installing NodeJs and Npm

Before you can begin using TypeScript, you'll need to make sure that Node.js and npm (Node Package Manager) are installed on your system. These tools are essential for managing your project’s dependencies.

Checkout the tutorial - How to install Nodejs and npm

Step 2: Initializing your project

Open your terminal, navigate to your project directory, and run npm init -y to create a package.json file with default settings.

npm init -y
step 2

Step 3: Installing Typescript

Run npm install typescript --save-dev to add TypeScript as a development dependency to your project.

npm install typescript --save-dev 
step 3

Step 4: Configuring Typescript

Execute npx tsc --init to generate a tsconfig.json file, which contains TypeScript compiler options and configurations.

npx tsc --init
step 4

package.json:

"devDependencies": {
"typescript": "^5.4.5"
}

Project Structure:

Project structure

Step 5: Creating Your First TypeScript File

Create index.ts file which will contain the sample TypeScript code.

Example: In this example, we define a constant variable greeting with the type string and assign it the value "Hello, GeeksforGeeks!". The console.log(greeting) statement then outputs this greeting message to the console. This simple application demonstrates basic TypeScript syntax, including type annotations and basic console logging.

JavaScript
// index.ts

const greeting: string = "Hello, GeeksforGeeks!";
console.log(greeting);

Step to Run Application: Run the application using the following commands from the root directory of the project

npx tsc
node index.js

Output:

output
Output

Now that your TypeScript project is set up, it’s time to bring your skills to life! Explore our Top 15 TypeScript Projects and build exciting apps like password generators, drag-and-drop lists, and more.


Setting Up TypeScript in Your Project
Article Tags :

Explore