Lesson 1 of 13
Hello, TypeScript!
Write and run your first TypeScript file. You will see how types are added on top of ordinary JavaScript and how the code is compiled to run.
TypeScript files end in .ts. The TypeScript (tsc) transpiles them to plain JavaScript. Alternatively, ts-node runs TypeScript directly for scripts and development.
// hello.ts
function greet(name: string): string {
return `Hello, ${name.toUpperCase()}!`
}
console.log(greet("World")) // Hello, WORLD!
// TypeScript catches this at compile time — before you run the code:
// greet(42) // Error: Argument of type 'number' is not assignable to parameter of type 'string'# Compile to JS, then run:
tsc hello.ts
node hello.js
# Or run directly with ts-node:
ts-node hello.ts
# Compile entire project with tsconfig:
tsc --init # generates tsconfig.json
tsc # compiles everything in projectFinished reading?Mark it done to track your progress.
Tip: use the ← and → keys to move between lessons.