Getting started with TypeScript requires a Node.js environment installed.
You will use the Node Package Manager (NPM) to install the compiler globally.
Once installed, you can easily initialize and compile your code.
This step ensures your system is perfectly ready for development.
To compile TypeScript, you need the official compiler called tsc.
You can install it globally on your computer so it's always available.
This allows you to write SEO-friendly code in any directory easily.
# Run this in your terminal npm install -g typescript # Verify installation tsc -v
Every TypeScript project needs a configuration file for compiler options.
This file is called tsconfig.json and helps standardize your project.
Generating it is very simple and takes just a single command.
# Creates a new tsconfig.json file tsc --init # Now you are ready to code!
Browsers cannot natively run TypeScript files (.ts) directly.
You must compile them into JavaScript (.js) before execution.
This compiled code is what gets parsed and indexed by search engines.
# Compiles index.ts to index.js tsc index.ts # Run the resulting JS file node index.js
How do you globally install TypeScript using NPM?
Now that you have TypeScript installed, it is time to write code.
We will begin by exploring the most fundamental building blocks.
Let's move on to learning about the simple data types!