Setup & Fundamentals
What Is TypeScript?
TypeScript is a strongly typed programming language built on top of JavaScript.
- Created and maintained by Microsoft
- A superset of JavaScript — all valid JS is valid TS
- Not supported by browsers directly — must be compiled to JavaScript first
- If your TypeScript code has an error, it will run locally, but the build will fail when deploying
TypeScript errors are caught at compile time, not at runtime. This makes your codebase more predictable and safer.
Why Use TypeScript?
| Feature | Benefit |
|---|---|
| Compiles to JavaScript | Runs everywhere JS runs |
| Keeps your code evergreen | Future-proof and maintainable |
| Supported by all major libraries & frameworks | Angular, React, Vue, Node.js, etc. |
Type Safety means your application is protected from type errors at compile time.
- Languages like C#, Java, C, C++ are examples of type-safe languages
- TypeScript brings this safety to the JavaScript ecosystem
- Keeps your code free from
undefinedandnullsurprises - Types are stripped away when compiled to JavaScript — zero runtime overhead
How To Initialize A TypeScript Project
Prerequisites
- Install Node.js (use the latest LTS version)
Step-by-step Setup
# 1. Initialize a new Node project
npm init
# 2. Install TypeScript as a dev dependency
npm install typescript
# 3. Initialize TypeScript configuration
npx tsc --init
This creates a tsconfig.json in your project root, which controls how TypeScript compiles your code.
Using A Bundler
📝 Notes to be filled while learning
Understanding The TSConfig
📝 Notes to be filled while learning