TypeScript Get Started

Install the compiler and compile a file.

✍️ 3 exercises + code challenge in this lesson
  1. Install Node.js, then TypeScript: npm install -D typescript
  2. Create a config file: npx tsc --init
  3. Write app.ts and compile it: npx tsc → produces app.js.
  4. Run the result: node app.js

Frameworks like Vite and Next.js compile TypeScript for you automatically.

Key Takeaways: TypeScript Get Started

Mastering TypeScript Get Started helps you write clean and reliable TypeScript code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

TypeScript Get Started Code Example

TypeScript
function greet(name: string): string {
  return `Welcome, ${name}!`;
}
console.log(greet("Sara"));
Output
Welcome, Sara!
Free sign-in required · Google login available

TypeScript Get Started Practice Exercises

Check what you learned in “TypeScript Get Started”.

/ 3 solved
Fill in the blank

Compile the project with the TypeScript compiler.

npx 
✓ Correct! Not quite. Try again.
Multiple choice

Which file configures the TypeScript compiler?

✓ Correct! Not quite. Try again.
Code challenge

Write a function double(n: number): number that returns n * 2 and log double(21).

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services