TypeScript is normally installed through npm. The package provides the
tsc compiler, which reads .ts files and writes
JavaScript files.
The compiler
Terminal
npm install --save-dev typescript npx tsc --version
Installing it in the project keeps the compiler version recorded with the
project. Use npx tsc to run that local version.
Your first file
Create hello.ts and compile it with
npx tsc hello.ts. This creates hello.js beside it.
hello.ts
const message: string = "Hello from TypeScript"; console.log(message);
At first, compilation may look unnecessary because the output is nearly identical. The next lessons show what TypeScript can check before that output is created.
Did you know my courses are all printer-friendly? This means you can easily export them to PDF or print them for later use.
