Curriculum
Course: TypeScript
Login
Text lesson

TS Introduction

What is TypeScript?

TypeScript is a syntactic superset of JavaScript that introduces static typing. Essentially, it builds upon JavaScript by adding syntax that enables developers to define types.

When we say TypeScript is a “Syntactic Superset,” it means it uses the same core syntax as JavaScript but extends it by adding additional features.

Why should I use TypeScript?

JavaScript is loosely typed, making it hard to determine data types in the code. Without type information for variables and function parameters, developers must rely on documentation or guesswork.

TypeScript solves this by allowing explicit type definitions and catching type errors at compile time.

For example, TypeScript will flag an error when a string is passed to a function expecting a number, while JavaScript would not.

TypeScript performs type checking at compile time, meaning it verifies that the specified types are correct before the code is executed, rather than during runtime.

How do I use TypeScript?

A typical approach to using TypeScript is through the official TypeScript compiler, which converts TypeScript into JavaScript.

Many popular code editors, like Visual Studio Code, offer built-in TypeScript support and can display errors in real-time as you write code.