TypeScript - First Program

Project setup

mkdir ts-hello && cd ts-hello
npm init -y
npm i -D typescript tsx
npx tsc --init
mkdir src

Hello world

// src/index.ts
const greet = (name: string) => `Hello, ${name}!`;
console.log(greet("TypeScript"));

Run without building

npx tsx src/index.ts

Build and run

npm run build
node dist/index.js

Compare output

Open dist/index.js and see the compiled JS. With newer targets, code is close to your TS.