TypeScript - Home
TypeScript Tutorial
Section titled “TypeScript Tutorial”TypeScript lets you write JavaScript the way you really want to. TypeScript is a strongly typed superset of JavaScript that compiles to plain JavaScript. It supports modern JavaScript features alongside a powerful static type system including classes, interfaces, generics, and more. Popular frameworks like Angular are built with TypeScript, and it’s widely adopted in React, Vue, and Node.js development for building robust, scalable applications.
Audience
Section titled “Audience”This tutorial is designed for developers familiar with JavaScript (especially ES6+ features) and object-oriented programming concepts. Programmers coming from statically-typed languages like Java or C# will find TypeScript’s type system familiar and beneficial.
Prerequisites
Section titled “Prerequisites”A good understanding of modern JavaScript (ES6+ syntax like let/const, arrow functions, classes, modules) and fundamental programming concepts is recommended to make the most of this tutorial.
Try it Yourself!
Section titled “Try it Yourself!”You can edit the code below and run it, or try it in the online TypeScript Playground.
// Example: Basic TypeScriptconst course: string = "TypeScript Fundamentals";let lessonCount: number = 10;
function printCourseInfo(title: string, count: number): void { console.log(`Course: ${title}, Lessons: ${count}`);}
printCourseInfo(course, lessonCount);
lessonCount = 12; // Allowed (let)// course = "Advanced TypeScript"; // Error: Cannot assign to 'course' because it is a constant.
printCourseInfo(course, lessonCount);On compiling, it will generate JavaScript code similar to this (depending on target settings):
var course = "TypeScript Fundamentals";var lessonCount = 10;function printCourseInfo(title, count) { console.log("Course: ".concat(title, ", Lessons: ").concat(count));}printCourseInfo(course, lessonCount);lessonCount = 12; // Allowed (let)// course = "Advanced TypeScript"; // Error: Cannot assign to 'course' because it is a constant.printCourseInfo(course, lessonCount);