TypeScript Tutorial: All Articles Grouped by Topic

All TypeScript tutorials on howtodoinjava.com, grouped by topic: basics, types, operators, arrays, collections, functions, interfaces and classes.

angular-typescript

TypeScript is a programming language from Microsoft that adds static types to JavaScript. We write .ts files with type annotations, and the TypeScript compiler checks them for type errors and turns them into plain JavaScript that runs in any browser or in Node.js. Errors such as calling a method on undefined or passing a string where a number is expected show up while we write the code instead of in production.

We use TypeScript for JavaScript projects that grow beyond a few files, such as a React front end or a Node.js REST API, where a renamed field or a wrong argument type would otherwise reach the users.

A first TypeScript program needs Node.js and one npm package. The following example installs TypeScript 7.0.2 in a new Node.js 22 project, and then compiles and runs a one-line file.

npm init -y
npm install --save-dev typescript@7.0.2
echo 'const user: string = "Lokesh"; console.log("Hello " + user);' > hello.ts
npx tsc hello.ts            # creates hello.js
node hello.js               # Hello Lokesh

Notice that tsc writes hello.js next to hello.ts, and node runs that JavaScript file, not the TypeScript source.

Node.js 22.18 and newer can also run a .ts file without compiling it, with node hello.ts, because it removes the type annotations before running the file. Node.js does not check the types, so we still run tsc to find type errors.

This page is the starting point for every TypeScript tutorial on this site. We grouped the articles by topic and ordered them so that a beginner can read them from top to bottom, and each article has a runnable project in the TypeScript-Examples repository on GitHub.

1. Getting Started

Start here if TypeScript is new to you. These articles explain what TypeScript adds to JavaScript and how the compiler and tsconfig.json work, and they cover variables and loops.

2. Types and the Type System

The type system is the reason to use TypeScript. These articles go from the basic types to unions, literal types, enums and dates.

3. Operators

These articles cover each group of operators, with the cases where TypeScript reports an error that JavaScript would accept.

4. Arrays

Arrays are the most common collection in TypeScript code. The overview covers typing arrays, and the other articles go deep on one operation each.

5. Collections: Map, Set and Record

These articles cover the key-value and unique-value collections and how to choose between them.

6. Functions and Error Handling

These articles cover function parameters, overloads, generics, callbacks and exceptions.

7. Interfaces and Classes

Readers coming from Java will find the familiar concepts here, along with the places where TypeScript works differently.

8. Conclusion

For a structured path, we read the Getting Started and Types groups first, then Arrays and Collections, and finally Functions and Interfaces and Classes. Every article starts with a quick-reference snippet, so the groups also work as a reference when we need one answer fast.

9. References

The official TypeScript documentation is the source for the language rules used in these tutorials.

Happy Learning !!

Source Code on Github

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.