Loading lessons...
Getting Started with TypeScript
What is TypeScript?
TypeScript is a typed superset of JavaScript created by Microsoft. It adds static typing to JavaScript and compiles down to plain JavaScript that runs in any browser or Node.js environment.
Key Benefits
| Feature | Description |
|---|---|
| Catch Errors Early | Uncovers type errors at compile time rather than runtime. |
| Enhanced Tooling | Provides auto-completion, refactoring, and inline docs in IDEs. |
| Clear Documentation | Type definitions serve as explicit code documentation. |
| Modern JS Features | Supports latest ECMAScript proposals compiled to older targets. |
Installing and Running TypeScript
You can install the TypeScript compiler (tsc) globally or locally using npm:
npm install -g typescript
To compile a TypeScript file (.ts) to JavaScript (.js):
tsc index.ts
This creates index.js which can be executed in any JavaScript engine.
TL;DR
- TypeScript is a typed superset of JavaScript.
- TypeScript code is compiled to JavaScript via the
tsccompiler. - It catches errors early at compile time and improves developer productivity.