The language has been built as an open-source project, licensed under the Apache License 2.0, has a very active and vibrant community, and has taken off significantly since its original inception.
To get started with TypeScript and try out all the examples, you can either install the TypeScript transpiler on your computer (more about this in the following paragraph), use the official online playground or any other online solution you prefer.
In case you want to try the examples locally, you need to install the command-line transpiler, which runs on Node. First, you need to install Node.js and npm on your system. Then, you can create a Node.js project and install the TypeScript transpiler package:
## Create a new directory for your project mkdir typescript-intro ## Make your project directory the current directory cd typescript-intro ## Initialize a new Node.js project npm init -y ## Install the TypeScript compiler npm i typescript
This will install the
tsc (TypeScript Compiler) command in the current project. To test the installation, create a TypeScript file called
index.ts under your project directory with the following code:
## transpiling index.ts to index.js npx tsc index.ts
This will generate a new file called
index.js with the exact same code of the TypeScript file. Use the
node command to execute this new file:
## this will output 1 node index.js
Note: TypeScript versions can have substantial differences even though they get released as minor revisions. It's common to bump into transpilation problems after a minor version update. For that reason, it is better to install TypeScript locally in your project and execute it using
npxwhen needed instead of relying on a global TypeScript installation.
Learn TypeScript | TypeScript Crash Course | TypeScript Tutorial for Beginners: My goal with this courses is just give your the fundamentals of the language, show you what TypeScript is and how to use it. We as developers don't have time neither can we afford to spend too much time on any tehcnology.