Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • TypeScript Tutorial
  • TS Exercise
  • TS Interview Questions
  • TS Cheat Sheet
  • TS Array
  • TS String
  • TS Object
  • TS Operators
  • TS Projects
  • TS Union Types
  • TS Function
  • TS Class
  • TS Generic
Open In App
Next Article:
How to Setup a TypeScript Project?
Next article icon

How to Setup a TypeScript Project?

Last Updated : 25 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In the world of modern web development, TypeScript has emerged as a powerful superset of JavaScript, offering static typing and improved tooling. Its strong typing system helps developers catch errors early during development, leading to more maintainable and scalable code. Whether you're starting a new project or integrating TypeScript into an existing JavaScript codebase, setting up a TypeScript project correctly from the start is crucial for long-term success.

How-to-Setup-a-TypeScript-Project-copy

In this article, we'll walk you through the entire process of setting up a TypeScript project. By the end of this article, you'll have a fully functional TypeScript project that is ready to be developed and scaled.

Prerequisites

  • Nodejs : TypeScript requires Node.js to work.
  • npm (Node Package Manager): npm helps manage dependencies in your project.
  • Typescript tutorial

Steps to Setup TypeScript Project

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.


Next Article
How to Setup a TypeScript Project?

G

gauravggeeksforgeeks
Improve
Article Tags :
  • GBlog
  • Web Technologies
  • TypeScript
  • Web-Tech Blogs

Similar Reads

    How to Set Up a Vite Project?
    Vite is a modern front-end build tool that offers a fast development experience by using native ES modules in the browser. It provides a lean and efficient setup for building JavaScript applications with a focus on performance and simplicity. PrerequisitesNodejsReactJavaScript Approach We have discu
    2 min read
    How to add TypeScript in Next.js ?
    In this article, we will learn how to add TypeScript in Next.js.Why should we use TypeScript in our project? The fundamental concept of TypeScript is that it is type-strict, which means that each entity, be it a variable, a function, or an object has a definite data type. It allows minimum bugs in t
    5 min read
    How to Test TypeScript with Jest?
    Jest, a powerful JavaScript testing framework, seamlessly integrates with TypeScript, providing all the tools needed to write and run tests for your TypeScript code, ensuring quality and reliability. It handles TypeScript compilation automatically, offers features like mocking and code coverage, and
    3 min read
    How to import a module in Typescript ?
    Before starting with importing modules, first of all, we need to know the basics of modules in TypeScript. We know that JavaScript has come with the concept of modules from the ES6 version in 2015 and by 2020 had broad support in most web browsers and JavaScript runtimes. TypeScript also shares the
    5 min read
    Top 15 TypeScript Projects With Source Code
    TypeScript is a powerful, statically typed superset of JavaScript that enhances code quality and maintainability, making it a popular choice for modern web development. From building scalable applications to creating robust front-end and back-end systems, TypeScript brings structure and reliability
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences