This repository should help you get an understanding of TypeScript. It is aimed at beginners that may have no prior experience with TypeScript, or programming in general. It is a work in progress, and I will be adding more content as I go along.
This repository is organized in many subfolders, each of which represents a chapter. Each chapter comes with a README.md file that explains the concepts that will be covered in that chapter. It also contains a task.ts code file that you should open and complete with your own code.
Every subfolder in this repository contains a README.md file. This file acts as a starting point for each chapter, providing instructions on how to approach the chapter.
Unfortunately, setting up your computer for programming is not always straightforward. However, it can be broken down into a few steps, each of which is not too difficult by itself. Try to follow the instructions below, and if you run into any issues, feel free to ask for help!
You will need to install Git to clone this repository to your local machine. You can download Git here.
Git is a so-called version control system, which allows you to keep track of changes you make to your code. This is extremely useful, as it allows you to go back to previous versions of your code if you accidentally break something. It also allows you to collaborate with others on the same codebase.
Git is a very powerful tool, although it can be quite confusing at times. For now, all you need to do is install it though, and Visual Studio Code will take care of the rest.
Programming is easiest and most efficient in something called an Integrated Development Environment (IDE). This is a program that is built specifically for writing code, and makes it more fun and enjoyable!
I recommend Visual Studio Code, a free code editor developed by Microsoft. You can download it here.
To get started, clone this repository to your local machine. The easiest way to do this is to select Clone repository
in Visual Studio Code's welcome screen.
Next, it will prompt you to enter the url of the repository you want to clone. For this repository, the url is https://github.com/robot-controller/typescript-tutorial.git
.
After you have entered the url, you can select a folder on your local machine where you want to clone the repository. This is where all the files in the repository will be stored.
After you have selected a folder, Visual Studio Code will clone the repository to your local machine. This might take a few seconds, depending on your internet connection.
After the repository has been cloned, you should see a new window in Visual Studio Code that shows the contents of the repository.
All major operating systems come with a so-called terminal. This is a program that allows you to interact with your computer using text commands. You can use the terminal to run programs, navigate your file system, and much more.
In Visual Studio Code, you can open the terminal by selecting Terminal
in the top menu, and then New Terminal
.
The terminal will open at the bottom of the window.
Try typing echo "Hello, world!"
in the terminal and pressing enter. This should output Hello, world!
in the terminal.
Why echo "Hello, world!"
? echo
is a command that prints the text that follows it to the terminal. Hello, world!
is a common phrase used in programming for the first program you write in a new language.
Node.js is the program that will later run the TypeScript code you write.
I recommend using nvm (Node Version Manager) to install Node.js. You can find instructions on how to install nvm e.g. here, although there's many other tutorials available.
With nvm installed, you can install Node.js (version 22.7.0) by running the following command in your terminal:
nvm install v22.14.0
Next, if you have multiple versions of Node.js installed, you can set the default version to 22.14.0 by running:
nvm alias default v22.14.0
You can verify that you have installed the correct version of Node.js by running:
node -v
This should output v22.14.0
.
Yarn is a package manager: a program that allows you to use code that others shared (which we call packages). You will need to install Yarn to install the packages that I used building this repository, so you can run it, too.
To install yarn, run the following commands in your terminal:
corepack enable yarn
and
yarn -v
This should ask you whether to download Yarn. You can confirm the download by just entering y
and pressing enter. Then, it should display the version of Yarn you have installed, e.g. 4.6.0
.