Are you a developer looking to enhance your skillset with TypeScript? You're in the right place! This comprehensive tutorial, replete with exercises, will guide you through the basics of TypeScript, helping you grasp the language's unique features and understand how it interacts with JavaScript.

TypeScript, a superset of JavaScript, brings static typing, class-based object-oriented programming, and other features to the JavaScript language. It's used to develop large-scale applications and is particularly popular in the Angular ecosystem. Let's dive into our interactive TypeScript tutorial, designed to help you hands-on with various exercises and examples.

Getting Started with TypeScript
Before we dive into exercises, let's set up our development environment and understand the basics.

First, ensure you have Node.js (LTS) and npm installed. Install TypeScript globally via npm using the command: `npm install -g typescript`.
TS Config File

Create a `tsconfig.json` file to configure compile-time settings on a per-project basis. An example configuration file looks like this:
`{"compilerOptions": {"target": "es2018", "module": "commonjs", "outDir": "./dist", "strict": true, "esModuleInterop": true}, "include": ["src/**/*.ts"], "exclude": ["node_modules"]}`
Hello World in TypeScript
Now, create an `index.ts` file and write your first TypeScript program:

`let message: string = "Hello, World!"; console.log(message);`
TypeScript Data Types
TypeScript is a statically-typed language, meaning you'll declare types for your variables.
Primitive Types

TypeScript supports the following primitive types: `boolean`, `number`, `string`, `null`, `undefined`, `symbol`, and `any`.
Array & Object Types




















TypeScript allows type annotations for arrays and objects:
`let list: number[] = [1, 2, 3];` `let person: { name: string; age: number } = { name: "John", age: 30 };`
Functions in TypeScript
Functions in TypeScript follow the same syntax as JavaScript but add type annotations for parameters and return values.
Defining Function Types
You can define function types using a syntax similar to object types:
`let greet: (name: string) => void;`
Optional Parameters
TypeScript allows optional parameters, with a type of `?` denoting optional parameters.
Classes in TypeScript
TypeScript supports class-based object-oriented programming, similar to other statically-typed languages like Java and C++.
definir Class & Properties
Define a class with properties and methods:
`class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { console.log(this.greeting); } }`